Forum: Ruby on Rails rest-ish method for subsetting an index view?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D6434aa0b7b350f8c3ed0119d81b2ead?d=identicon&s=25 Roy Pardee (rpardee)
on 2009-02-27 23:58
(Received via mailing list)
Hey All,

My app keeps track of /people.  A Person has a .typical_role property,
which (right now) takes one of the following values: ["Programmer",
"Investigator", "Project Manager", "Other"].

What's the best/easiest/neato-cool way to allow users to specify which
subset of people they want to see on the URL?  I'm thinking of urls
like:

  /people/project_managers
  /people/programmers

etc.

If I wanted to do that, what would I have to do to my routes.rb,
controller, etc.?  Right now all I've got is:

  map.resources :people

Would it be better/easier to just try to have e.g., a /project_managers
index (resource? is that the right terminology?) right at the root of
the app & not try to hang if off of /people at all?

Many thanks!

-Roy

Roy Pardee
Research Analyst/Programmer
Group Health Center For Health Studies (Cancer Research Network)
(206) 287-2078
Google Talk: rpardee
170e2a48994775e4c298c302e6814f81?d=identicon&s=25 Starr Horne (Guest)
on 2009-02-28 19:11
(Received via mailing list)
You could always do something like this:

map.connect '/people/:role', :controller => 'people', :action => 'index'

Personally, I'd probably go with a url structure like
/people/filter/programmers:

map.resources :people, :collection => { :filter => :get }

SH
This topic is locked and can not be replied to.