Hi!
I’m having a bit of trouble with routes requirements for resources.
Using Rails 2.0.2, I tried to specify that an explorer id (which
actually is its login as a permalink) could contain dots, minus, or
underscores thanks to requirements :
##################################################
######## config/routes.rb
map.resources :explorers,
:requirements => { :id => /[\w.-_]+/},
:collection => { :search => :post}
:member => { :languages => :any,
:map => :get}
####### a/models/explorer.rb
class Explorer < ActiveRecord::Base
def to_param
login
end
end
##################################################
For explorers without ‘.’ in their login, every route works fine and
explorers
explorers/john
explorers/john/map
are all recognized.
But for example :
explorers/john.doe
will get recognized while
explorers/john.doe/map
will raise:
Routing Error
No route matches “/explorers/john.doe/map” with {:method=>:get}
It seems like :requirements option is only taken into account for
basic resources actions, not the one that have been added via :member.
Is there a way to force :requirements for :member actions, or do I
have to write usual routes individually and map them to
“#{action}_explorer”?
Thanks a lot for your attention & have a nice week-end,
Eric