Just to clarify what I''m talking about below in the latest revision of AWDWR (2nd edition) pdf page 402 - Section "Adding Your Own Actions" The example shows how one can add an interface to allow people to fetch just recent articles with a call in the routes.rb map.resources :articles, :collection => {:recent => :get} end Questions: Since it doesn''t show the action itself that gets created I''m wondering 1) is this another url that would have a link in the index page OR would it apply to the entire route where a show would only bring up the most recent articles ? I''m thinking my idea (below) doesn''t fit into this method but wondering and unclear. On 9/27/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 9/27/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Is there a way to add something say in the line - config.rb/ > > map.resources :articles, :collection {:user_id =>:get} > > so that only articles by the user who posted would be listed ? > > > > -- > > Okay , I just need some clarification on a few things - > I''m assuming I define the action in the controller (duh) , and I want > to make it protected. > Since all the restful actions are params[id], I''m trying to figure out > a generic action to add the condition of user id on there. > > Stuart > > -- > http://en.wikipedia.org/wiki/Dark_ambient >-- http://en.wikipedia.org/wiki/Dark_ambient --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 9/28/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Just to clarify what I''m talking about below in the latest revision of > AWDWR (2nd edition) pdf page 402 - Section "Adding Your Own Actions" > The example shows how one can add an interface to allow people to > fetch just recent articles with a call in the routes.rb > map.resources :articles, :collection => {:recent => :get} end > Questions: > Since it doesn''t show the action itself that gets created I''m > wondering 1) is this another url that would have a link in the index > page OR would it apply to the entire route where a show would only > bring up the most recent articles ? I''m thinking my idea (below) > doesn''t fit into this method but wondering and unclear.Stuart, If you use the ActionController::Routeing::Routes from the console, as it shows in the book (sorry I can''t find the page number but I was reading it last night. It''s in the same section as your refering to) use the line as shown puts rs.routes.map(&:to_s) but with a grep on the end puts rs.routes.map(%:to_s).grep /articles/ you will get a list of actions for the articles controller. This will show you that there is a route for GET /articles;recent (I think this is it. I don''t have ruby with me at the moment.) that maps to :controller => ''articles'', :action => ''recent I''m doing this from memory so sorry if there''s something not quite right. The long and short of it is that it will map to the recent action in the articles controller. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---