This project is archived and is in readonly mode.
responder method for controller
Reported by Jan De Poorter | February 24th, 2010 @ 12:26 PM | in 3.0.2
I'm developing a project in Rails 3.0 and I love the Responder functionality. I'm currently using around 4 to 5 different responders per controller, and bumped into the problem that I had to create custom Responders for different sets of functions. I had a PaginationAndSortingResponder, a SortingAndFlash responder, a PaginationAndSortingAndFlash responder, and so on.
I'd think it better to have a way to cherry-pick the responders you want in a easy way. I came up with this syntax:
class InvitationController < ApplicationController
responder :pagination, :flash
end
This codes loads up a responder with PaginationResponder and FlashResponder. I'm currently implementing this code in ApplicationController this way:
class ApplicationController < ActionController::Base
protect_from_forgery
class << self
def responder *responders
if responders.any?
responder_class = Class.new(ActionController::Responder)
responders.each do |responder|
responder = responder.is_a?(Module) ? responder : "#{responder.to_s.classify}Responder".constantize
responder_class.send(:include, responder)
end
self.responder = responder_class
else
super()
end
end
end
end
I'd write a patch but with the new structure I'm not sure where
I should put this method. I see the responder
definition now is in ActionController::MimeResponds
,
is this also the place I should implement this function? (if
wanted, ofcourse)
Comments and changes to this ticket
-
Jan De Poorter March 3rd, 2010 @ 09:53 AM
While using it for about 6 days I notice I'd also like this method to inherit from ApplicationController, but possibility to override. Wondering how to do this though :-)
-
Jan De Poorter March 15th, 2010 @ 03:33 PM
Figured this was more of a plugin thing for now. Moved it to http://github.com/DefV/easy_responders
-
José Valim March 15th, 2010 @ 03:37 PM
- State changed from new to invalid
- Milestone cleared.
Hey, I was talking with Jeremy and we just realized the same. Although, I was thinking in merging it with my responders gem:
http://github.com/plataformatec/responders
Are you in mood for a patch or should I implement it myself? :)
Regards!
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to Low
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>