resources_controller and response_for to be merged?

0 views
Skip to first unread message

Ian White

unread,
Feb 3, 2008, 9:24:07 AM2/3/08
to resources_controller
Hi List,

I'm thinking about including response_for into resources_controller.
This won't affect anyone who uses their own actions module. It should
not affect anyone who uses the default rc actions, and will make their
life easier when it comes to overriding behaviour of actions.

The reason I want to do this is to do with the recent xml response
thread. A legitimate concern was raised that a user might do
resource_controller_for :posts, without realizing that posts/1.xml
will just work, and by default will display all of the attributes of
post. The suggestion is to make rc actions not inclde xml by default,
but say pass :xml_response => true to turn on xml response for all
actions. It will be much cleaner, and less code, to use response_for
to achieve this.

To recap, response_for will let you do something like this (the
example is RESTful controller + atom feeds on index and show)

resources_controller_for :posts

response_for :index do |format|
format.atom { # render atom feed, or template or whatever }
end

I'm thinking I'll keep response_for as a separate plugin, the relevant
bits of which are externaled to the rc base.

I'd appreciate feedback before making this move.

Cheers,
Ian

Chris Hapgood

unread,
Feb 3, 2008, 3:12:04 PM2/3/08
to resources_...@googlegroups.com
I can appreciate the concern over data leakage, but I don't think explicitly
enabling each MIME type is the answer. What next, :json_response => true,
:xml_response => true?

I'm not necessarily opposed to including some of response_for in RC, just
wary of featuritis. I already wish there was a little more distinction in
RC between the identification of REST resources versus helpers for
generating URLs. I see them as generally distinct with some overlap.
Response_for seems very distinct (to the point that I have never needed it)
from either of these, and I would hope that it remains that way.

Short version: -1 if all it does is support an xml_response => true feature.

-Chris


Chris Hapgood
Phone: +1 434 989 8584
Skype: chris.hapgood
Email: cc...@hapgoods.com


Hi List,

resources_controller_for :posts

Cheers,
Ian


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.19.19/1256 - Release Date: 02/02/2008
13:50

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.19.19/1256 - Release Date: 02/02/2008
13:50

Reply all
Reply to author
Forward
0 new messages