# Using a domain name in a Rails route

**URL:** <https://www.ruby-forum.com/t/using-a-domain-name-in-a-rails-route/165059>\
**Category:** Rails\
**Created:** [April 8, 2009, 6:23pm UTC](https://www.ruby-forum.com/t/using-a-domain-name-in-a-rails-route/165059 "2009-04-08T18:23:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve\_at\_trend](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/258eb7/32.png) [@steve\_at\_trend](https://www.ruby-forum.com/u/steve_at_trend)\
**Post date:** [April 8, 2009, 6:23pm UTC](https://www.ruby-forum.com/t/using-a-domain-name-in-a-rails-route/165059/1 "2009-04-08T18:23:09Z")

</div>

I’m having trouble getting a domain name to be recognized as a valid :id  
in the following Rails 2.2.2 route. I hope somebody has run across this  
problem before and can shed some light on why this does not work…

routes.rb contains:

map.resources :domains,  
:requirements =\> { :id =\> /[a-zA-Z0-9-.]+/ },  
:collection =\> { :visible =\> :get },  
:member =\> { :owner =\> :put },  
:only =\> [:index, :show, :create, :owner, :destroy,  
:visible] do |domain|

When I attempt to PUT against my server for this route:  
[http://localhost:3000/domains/test.com/owner](http://localhost:3000/domains/test.com/owner)

I see an ActionController::RoutingError (see below). As I understand  
it, the regex passed to :requirements should match “[test.com](http://test.com)” and  
determine that as the :id? Am I missing something here?

Thanks in advance,  
Steve

ActionController::RoutingError (No route matches  
“/domains/test.com/owner.xml” with {:method=\>:put}):  
/Users/Steve/.gem/ruby/1.8/gems/actionpack-2.2.2/lib/action\_controller/routing/recognition\_optimisation.rb:66:in  
`recognize_path' /Users/Steve/.gem/ruby/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/route_set.rb:386:in `recognize’  
/Users/Steve/.gem/ruby/1.8/gems/actionpack-2.2.2/lib/action\_controller/dispatcher.rb:182:in  
`handle_request' /Users/Steve/.gem/ruby/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:in `dispatch\_unlocked’  
/Users/Steve/.gem/ruby/1.8/gems/actionpack-2.2.2/lib/action\_controller/dispatcher.rb:123:in  
`dispatch' /Users/Steve/.gem/ruby/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in `synchronize’  
/Users/Steve/.gem/ruby/1.8/gems/actionpack-2.2.2/lib/action\_controller/dispatcher.rb:122:in  
`dispatch' /Users/Steve/.gem/ruby/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:132:in `dispatch\_cgi’  
/Users/Steve/.gem/ruby/1.8/gems/actionpack-2.2.2/lib/action\_controller/dispatcher.rb:39:in  
`dispatch' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process’  
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/rails.rb:74:in  
`synchronize' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process’  
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:159:in  
`process_client' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `each’  
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:158:in  
`process_client' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run’  
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:285:in  
`initialize' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new’  
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:285:in  
`run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize’  
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:268:in  
`new' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run’  
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/configurator.rb:282:in  
`run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each’  
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/configurator.rb:281:in  
`run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run’  
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/command.rb:212:in  
`run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281 /usr/bin/mongrel_rails:19:in `load’  
/usr/bin/mongrel\_rails:19

Rendering  
/Users/Steve/.gem/ruby/1.8/gems/actionpack-2.2.2/lib/action\_controller/templates/rescues/layout.erb  
(not\_found)
