Friday, June 6, 2008

Uncountable Names in RESTful Routes

http://somethinglearned.com/articles/2007/03/19/how-to-uncountable-names-in-r...

While trying to create a “home” route in my Rails app, I encountered an ‘ActionController::RoutingError: home_url failed to generate from {:controller=>”home”, :action=>”show”} - you may have ambiguous routes, or you may…blah…blah…blah’

It turns out that if your route is uncountable, Rails will call a member URL (hence ‘show’) instead of the collection URL (i.e., ‘index’).

Trevor at ‘Something Learned’ had the solution:

# routes.rb

map.resources :home, :singular => :home_instance

Thanks Trevor!

No comments:

Post a Comment