Hello Friends,
I have a requirement where I want to Have the following url “http://www.example.com/andy.something/office” where **andy.something is a dynamic value.**Now I am using a namespace which is :controller=>“system/office/office_profiles”
and I have declared the route
map.office_profile_link ‘/:profile_link/office’, :controller => “system/office/office_profiles”, :action => “show”, :conditions => { :method => :get }
But when I am trying to access
http://www.example.com/andy.something/office
Getting the following error
Routing Error
No route matches "/andy.something/office" with {:method=>:get}
So Please let me know where I am getting wrong.
Thanks
Abhis.
Hello Friends,
I have a requirement where I want to Have the following url "http://www.example.com/*andy.something*/office" where *andy.something is a
dynamic value.
*Now I am using a namespace which is
:controller=>"system/office/office_profiles"
and I have declared the route
map.office_profile_link '/:profile_link/office', :controller =>
Are you sure you want "_link" as part of the route name? Remember the
*_url and *_path helpers are generated from your existing named
routes. But thats not the issue at hand.
"system/office/office_profiles", :action => "show", :conditions => { :method
=> :get }
But when I am trying to access
http://www.example.com/*andy.something*/office
Getting the following error
Routing Error
No route matches "/andy.something/office" with {:method=>:get}
So Please let me know where I am getting wrong.
Thanks
Abhis.
You're not doing anything necessarily wrong; Rails just automatically
delimits bound parameters on periods. Tell the route to expect a "."
in the :name parameter by adding a requirement (http://
guides.rubyonrails.org/routing.html#route-requirements) to the route
like
map.office_profile_link '/:profile_link/office', :controller =>
"system/office/office_profiles", :action => "show", :conditions =>
{ :method => :get }, :name => /(?:\w+)(?:\.\w+)?/ # of course using an
appropriate regex for your cause