Currently I am working on my first REST application and so far I
really like te clairity it brings to the project but there is one
thing I do not understand. My routes.rb looks something like this:
map.resources :projects do |projects|
projects.resources :forums, :has_many =>[:posts] do |forum|
forum.resources :topics, :name_prefix => nil do |topic|
topic.resources :posts, :name_prefix => nil
topic.resource :monitorship, :controller
=> :monitorships, :name_prefix => nil
end
end
projects.resources :posts, :name_prefix => 'all_', :collection =>
{ :search => :get }
end
I was under the impression that calling fourm_path(@project, @forum)
would be valid. However this is not. I need to call
project_forum_path(@project, @forum). Alright I can go with that, but
a little further on I want to create a edit link for a topic:
edit_topic_path(@project, @forum, @topic). This works! Why? I would
expect project_forum_edit_topic(@project, @forum, @topic) or
edit_project_forum_topic(@project, @forum, @topic).
Can someone shed some light on this?
I was under the impression that calling fourm_path(@project, @forum)
would be valid. However this is not. I need to call
project_forum_path(@project, @forum). Alright I can go with that, but
a little further on I want to create a edit link for a topic:
edit_topic_path(@project, @forum, @topic). This works! Why?
Can you provide your entire routes.rb file? It certainly doesn't seem
like it should work.
Aha! That must be it. I am new to this whole REST thing and I'm
continuing work on an app made by someone else. Why would you want to
set :name_prefix => nil? Just to make your method names shorter? Or
does it serve any other purpose?