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?

4 Answers 4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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 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.
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

Comments

1

I think it is app/controllers/proto_controller.rb

And rails convention is to pluralize model name in controllers.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.