1

Am I configuring the default route correctly? Currently my route is set to:

root :to => 'proto#index'

When I do I am receiving the following error:

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

What file do I need to change?

notapatch
  • 6,569
  • 6
  • 41
  • 45
Blackninja543
  • 3,639
  • 5
  • 23
  • 32

4 Answers4

5

You are looking for app/controllers/proto_controller.rb

It should contain something like the following

class ProtoController < ApplicationController

  def index
  end

end

Then you want to make a file at app/views/proto/index.html.erb that contains the html for the page.

declan
  • 5,605
  • 3
  • 39
  • 43
  • 1
    It's been a while since you needed to create a dummy action in order your route to work. Make just a view, it should be enough. – jdoe Sep 10 '12 at 20:21
  • @jdoe That's fair, but the OP is pretty new to Rails, and I thought it might make things a little clearer to just show the method. – declan Sep 10 '12 at 22:14
2

There are several things you should check.

Do you have a controller called "proto"?

If so, do you have index action in your proto controller?

Ideally, your proto controller should be something like ..

class ProtoController < ApplicationController
  def index
    @protos = Proto.all
  end
end
Jason Kim
  • 18,102
  • 13
  • 66
  • 105
1

I think it is app/controllers/proto_controller.rb

And rails convention is to pluralize model name in controllers.

Nick Kugaevsky
  • 2,935
  • 1
  • 18
  • 22
0

root :to => 'proto#index' should go in config/routes.rb

ProtoController should be defined in app/controllers/proto_controller.rb

class ProtoController < ApplicationController
  def index
    # ...
    respond_to do |format|
      format.html
    end
  end
end

This action will look for the template defined by app/views/proto/index.html.erb and render it out.

niiru
  • 4,982
  • 1
  • 17
  • 13