Re: AWDWR Question - was: Edge Restful question

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 A. [email protected] wrote:

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


Dark ambient - Wikipedia

On 9/28/06, Dark A. [email protected] wrote:

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.