I am working on Rails 2.3.11. If I have a url like http://www.abc.com/users/e.f.json , I expect the id to be ‘e.f’ and the expected format to be ‘json’. Can someone please suggest a way to do it.
Thank you!
I am working on Rails 2.3.11. If I have a url like http://www.abc.com/users/e.f.json ,
Share
Because of the :format convention, Rails will parse all parameters without any dots. You can have route parameters with dots if you want:
But since both ‘*’ and ‘+’ regex wildcards are greedy, it will ignore the (.:format) param completely.
Now, if you absolutely need to have dots in the username, there is a pseudo-workaround that could help you:
The downside is that you have to include the dot in the :format regex, otherwise it would be caught by the username expression. Then you have to handle the dotted format (e.g.: .json) in your controller.