You can already do something like this:
In your routes:
get "foo(.:format)(.:compression)" => "foo#index"
Then in your controller:
respond_to do |format|
format.xml do
if params[:compression] == "zip"
render ...
else
render ...
end
end
end
That being said a format of csv.zip is not `csv` since it is zipped and it is
not purely `zip` since that gives no indication of the actual contents of the
file. Having some kind of built in support for this would be expected by me if
I was trying this out for the first time.
Though if we were to add this feature I would expect it to be greedy so if you
visit `foo.csv.zip` it would first look for a `csv.zip` format and if that was
not found, it would look for a `csv` format as a backup. I haven't checked into
the implementation implications. If it is simple to implement with no
performance impact I would be :+1: otherwise it's not enough of a win as you
can already do something like this (as above).
If someone implements this cc/ me on the PR and I'll be happy to comment.
--
Richard Schneeman
http://heroku.com
@schneems (http://twitter.com/schneems)
On Saturday, August 4, 2012 at 1:24 PM, Alexey wrote:
> On Saturday, August 4, 2012 8:09:16 PM UTC+2, Farski wrote:
> > I'm having a hard time thinking of use cases for this outside of zip or
> > other archive/compression formats. In the case of user/1.xml.zip, likely
> > you'd want an existing users_controller#show that returns xml to continue
> > to operate as it currently does, but you'd want the result to be zipped. If
> > there aren't lot (any?) of other situations where stack formatting is used,
> > perhaps this would be better handled outside the scope of rails; let it
> > keep doing what it's doing and maybe check the request URL for compression
> > in rack on the way in and do the compression on the way out. If there are
> > more general uses of this, it's still unlikely that you'd want a single
> > controller action to handle both creating the xml and zipping it if
> > necessary.
> >
>
>
> Maybe "csv.zip" or "pdf.zip" make better sense.
> I can of course define formats "csv_zip" and "pdf_zip" and use them, but i
> would prefer "csv.zip" and "pdf.zip".
>
> - Alexey.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-core/-/nvcKZqSESFAJ.
> To post to this group, send email to [email protected]
> (mailto:[email protected]).
> To unsubscribe from this group, send email to
> [email protected]
> (mailto:[email protected]).
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-core?hl=en.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.