This project is archived and is in readonly mode.
DRYing up respond_to: Allow multiple types in same responder
-
blj
Are you not supposed to return same data in every other format?
-
David Knorr
@blj: As a groundrule, yes, but you wouldn't paginate an RSS/Atom feed, would you? For example.
-
Ryan Bigg
Good point, good ticket.
+1
-
Jeffrey Hardy
Forgive me if I'm being naive, but can't you use format.any here?
def index respond_to do |format| format.html { @articles = Article.paginate(:page => params[:page]) } format.any(:atom, :rss) { @articles = Article.find(:all) } end end -
David Knorr
@Jeffrey Hardy: Yes, you can, and I must admit, I wasn't aware of that. But anyway I don't think it invalidates the patch. After all, the patch allows a more elegant syntax, and we can still use the any method as a catch-all type.
-
David Knorr
I would like to get this out of the way. First of all: Has anyone got any comments/questions/suggestions for improvements? If not, could this patch either be applied to core or marked as "wontfix"? Having this hanging around on Lighthouse serves no purpose.
-
José Valim
- State changed from new to wontfix
I agree with Jeffrey, any is the official API for several formats. :)
