Most Rails-y way to give different views of the same resource?

Posted by Nathan Long on Stack Overflow See other posts from Stack Overflow or by Nathan Long
Published on 2010-03-15T01:50:26Z Indexed on 2010/03/15 1:59 UTC
Read the original article Hit count: 290

Filed under:

In Rails, is there a canonical way of giving different views of the same resource?

For example, a directory of people, where each person can have multiple photos, phone numbers, email addresses, etc. The people, photos and phone numbers are actually different resources with their own RESTful actions.

But when viewing people, one page might shows everyone's name and associated photos; another page is names and associated contact information, formatted for printing.

Would it be more "Rails-y" to:

  • Create additional actions on the People controller besides the RESTful ones, like "index_with_contact_info"?
  • Create a different controller and a different group of views?

Neither seems quite right to me, but the first seems more likely. Any thoughts?

© Stack Overflow or respective owner

Related posts about ruby-on-rails