My homecontroller has:
def about()
end
And I have a rspec test that does GET ‘about’ and it fails saying that there is no route that matches.
doesn’t this map all actions in the controller:
resources :home
or do I have to explicitly state each action in the home controller?
resources :homesets up the default RESTful routes – index, show, new, create, edit, update, and destroy. Any additional routes have to be specified. It looks like you’re adding a simple collection route, so you’d specify it like this:This will give your the route ‘/home/about’. I assume this is Rails 3. If you’re in Rails 2.x, do it like so:
And from the command line, you can always see what routes you have available with this command:
I hope this helps!
EDIT: If you want a default route, you can add this:
This is a default route that will match any generic requests.
FULL ARTICLE: Routing in Rails 3 is its own beast. There have been a lot of questions about it lately, so I’ve created a very detailed article with code samples to help others:
Routing in Ruby on Rails 3
I created a companion Rails 3 app that can be downloaded to play around with, as well:
https://github.com/kconrails/rails3_routing
If you have any questions, please hit up my site and ask. Thanks!