--
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/-/e2wEpsceyPgJ.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-co...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
What about using a routing constraint for allowing the entire file extension?E.g. match "/download/:filename", :to => "downloads#download", :constraints => { :filename => /.+/ }
Also, there are request parameters, like sorting and filtering parameters, which are common to all formats, so i would like all formats and downloads to be processed by the same controller action.- 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/-/-ttQAFSi7NQJ.
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.
--
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.
I see no better way to name this format than 'csv.zip' (with Content-Type 'application/zip').
--
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/-/l1IhoVdtF4wJ.
But then you'd have 'csv.zip', 'xml.zip', etc be application/zip.If you want to support both in a controller action, what happens when someone requests /users with Accept application/zip? Which one wins?The .format notation is just a workaround for things that can't add/change the Accept header to the request (like HTML links), but it's just a workaround.Cheers,-foca
If the goal of this post is to change the functionality of `:format` to return "xml.zip", then I disagree. "xml.zip" is not a file extension, which I believe the `:format` param is intended to represent. Looking at the list of file formats, it is not on the list -- only "zip" is because it is still a zip file despite the "xml" preceding it.This is the same as saying that "tar.gz" is a file extension -- it's not. The "tar" before the "gz" indicates that this gzipped file probably contains a tar file, but the extension is still "gz". That's probably why the "tgz" file format was introduced.Just my 2 cents.
Matt, i was only proposing to parse the URL slightly differently, probably without impact for existing applications. I am already using both "csv" and "csv.zip" formats in my application (mostly for testing and experimenting), i only do not like that i have to access "csv.zip" like this: "/users.csv_zip".
Just out of curiosity, do you have any examples of multiple extensions where those other than the root extension aren't a compression or archive format? I ask in the context of this being considered a bad practice. To me, naming something anImage.jpg.zip.tar.gz means I started with a JPEG, and then stuck that inside a zip, then put the zip in a tar, then the tar in a gzip. Those "extra" extensions are all container formats, so it makes sense to show that there's a file of a different format nested inside them. If things become more arbitrary, say anImage.jpg.txt, which just returns the JPEG's binary data as text/plain, that doesn't really hold up for me. That seems presentational, not a text file containing a jpeg.If the only time that multiple extensions ever come into play is archive/compression, middleware still seems like a good option. The URL helpers could remain fairly consistent (eg, resource_path(@resource, :format => [:xml, :zip]) and the additional functionality be transparent. Rails really doesn't need to know it's happening as long as it's generating correct URLs. If zipping is far and away the most likely case for this (which I think is likely), resource_path(@resource, :zipped => :xml) may even make sense.Basically, for all the examples I've thought of, anytime multiple extensions are being used appropriately, the root extension is the only one that it makes sense to Rails to actually handle. But if there are examples to indicate otherwise I'd be interested to hear them.The only things I've gotten close on is like:/runs/1 => web view of a GPS recorded running route/runs/1.json => JSON version/runs/1.xml => XML version/runs/1.xml.gpx => XML that adheres to GPX standard/runs/1.xml.tcx => XML that adheres to TCX standardBut those last two, to me, are simply improperly name.
As far as your second set of examples, in foo.minimized.js, the ".minimized" part isn't really an extension; it's just part of the file name. If someone named their vCard 'John.Smith.vcf', Smith isn't an extension, they just happened to use a period in the file name. So I don't think those examples really apply. ".minimized" is just convention, it could just as easily have been "foo-minimized.js" since the mine type or format is remaining the same.