wweare
wweare

Reputation: 241

ActionNotFound (The action 'index' could not be found for CompaniesController):

I running a webrick, and shell show me this error

AbstractController::ActionNotFound (The action 'index' could not be found for CompaniesController): 

there is my routes.rb

  resources :companies do
    member do
      put :click_on
    end
    get :generator, on: :collection
  end
  root 'welcome#welcome_page'

the controller no index action

how fix it?

Upvotes: 0

Views: 1547

Answers (1)

fivedigit
fivedigit

Reputation: 18682

Add the index action (which is just a method) to your controller like the error message suggests:

class CompaniesController < ApplicationController
  def index
  end
end

Then add views to render:

<%# app/views/companies/index.html.erb %>
<h1>Companies Index</h1>

Read the Rails documentation for more information on how controller basics work.

Upvotes: 2

Related Questions