Got a quick question regarding the latest and greatest:
module ActionController
module Routing
SEPARATORS = %w( / ; . , ? )
Why is period (.) one of the separators? As it stands, the new routing
code doesn't recognize 'file.ext' as the last component of a URL, which
is sometimes defaulted to nil. See the generated code below.
I don't know everything about URL encoding, but it seems that period
isn't one of should-be-escaped characters in a URL.
Thanks in advance!
Doug.
--Generated code--
if (match =
/\A\/(user)\/(login|logout|show|list)(?:\/?\Z|\/([^\/;.,?]+)\/?)\Z/.match(path))
on 2006-08-01 06:18
on 2006-08-01 06:31
On Jul 31, 2006, at 9:18 PM, Doug Dupory wrote: > Got a quick question regarding the latest and greatest: > > module ActionController > module Routing > SEPARATORS = %w( / ; . , ? ) > > Why is period (.) one of the separators? As it stands, the new routing > code doesn't recognize 'file.ext' as the last component of a URL, > which > is sometimes defaulted to nil. See the generated code below. An extension is the natural way to specify a resource's mime type: /people/1.xml So it's now parameterizable: map.connect '/:controller/:id.:format', :action => 'show', :require => { :method => :get } class PeopleController .. def show # The :format param informs respond_to. respond_to do |wants| wants.html # renders the rhtml wants.xml { render :xml => @person.to_xml } end end GET /people/1 GET /people/1.html GET /people/1.xml jeremy
on 2006-08-01 17:43
Thank you, Jeremy, for the clear explanation! Indeed, it's quite a useful feature. However, the implementation of it has introduced a problem: a URL that's generated by the following route cannot be recognized by the same route. map.connect '/:controller/:action/:file', :defaults => (:file => nil} Note that .:format isn't specified, and then the file segment contains a dot, but url_for doesn't escape the dot. A bug? Doug. Jeremy Kemper wrote: > > An extension is the natural way to specify a resource's mime type: > /people/1.xml > > So it's now parameterizable: > map.connect '/:controller/:id.:format', :action => > 'show', :require => { :method => :get } > > class PeopleController .. > def show > # The :format param informs respond_to. > respond_to do |wants| > wants.html # renders the rhtml > wants.xml { render :xml => @person.to_xml } > end > end > > GET /people/1 > GET /people/1.html > GET /people/1.xml > > jeremy
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.