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 standard
But those last two, to me, are simply improperly name.



On Tuesday, August 7, 2012 6:57:19 AM UTC-4, Alexey wrote:
>
> Thanks for the ideas to use middleware to compress the response and to 
> pre-parse the URL, but i think i would like that it be possible for the 
> application to parse URLs with multiple extensions as well.
>
> If multiple extensions are not considered a 'bad practice' and if they can 
> be used to indicate 'composite formats', for the use by middleware for 
> example, why not to allow rails to take multiple extensions into account as 
> well?  Also, the views are generated by the application, so the application 
> has to know anyway at which url and with which Accept header to access 
> zipped CSV or PDF, to be able to generate a correct link or button element. 
>  So compression cannot be viewed as just an optional middleware 
> configuration independent of the applicaiton.
>
> If multiple extensions are discouraged and i need to use Accept header, 
> then
>   a. how to set it from an html <a> element? (I've seen that in HTML5 
> there is the "type" attribute, but i've read "it is purely advisory", does 
> it work?)
>   b. URL does not anymore determine the response completely, which i do 
> not like.
>   c. requesting /users.csv with Accept header application/zip looks to me 
> either strange or no better than requesting /users.csv.zip directly.
>
>
>

-- 
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/-/z2PakEoKgjcJ.
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.

Reply via email to