Dear list,
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?
Thanks a lot in advance!
Harm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---
> 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. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 10/31/07, harm <harmaarts@gmail.com> wrote:> > Dear list, > > 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 >You set :name_prefix => nil for :topics. -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
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?
My complete routes.rb:
ActionController::Routing::Routes.draw do |map|
map.home '''', :controller => ''projects''
map.resources :projects do |projects|
projects.resources :project_users
projects.resources :items, :collection => ''all''
projects.resources :documents
projects.resources :links
projects.resources :chat_messages, :collection => { :show_recent
=> :get}
projects.resources :private_messages
projects.resources :chat_messages
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
map.resource :user #singleton!
map.resource :session #singleton!
map.admin_home ''/admin'', :controller =>
''admin/projects''
map.namespace :admin do |admin|
admin.resources :projects
end
end
On Nov 1, 3:28 am, "Rick Olson" <technowee...@gmail.com>
wrote:> On 10/31/07, harm <harmaa...@gmail.com> wrote:
>
>
>
>
>
> > Dear list,
>
> > 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
>
> You set :name_prefix => nil for :topics.
>
> --
> Rick
Olsonhttp://lighthouseapp.comhttp://weblog.techno-weenie.nethttp://mephistoblog.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---