How to encode (.) Dot in url Rails

80 views
Skip to first unread message

Loganathan Sellapa

unread,
Jan 20, 2012, 7:38:46 AM1/20/12
to Rails
Hi All,

I am having routes like below to delete/list an user.

map.connect 'developer/:user_name/delete',:controller=>"developers",:action=>"delete",:method=>:delete

map.connect 'developer/:user_name/list',:controller=>"developers",:action=>"list",:method=>:get

While listing the user by encoding the Dot with %2E, i can see the success response http://localhost:3000/developer/testuser%2Ehu/list

But While trying to delete the user who containing the Dot(.), throws 404 error.

http://localhost:3000/developer/testuser%2Ehu/delete , thanks in advance

regards,
Loganathan



Tim Shaffer

unread,
Jan 20, 2012, 8:03:30 AM1/20/12
to rubyonra...@googlegroups.com
You have the  developer/:user_name/delete route set to use "delete" as the method, rather than "get"

Since browsers usually don't support sending requests other than post or get, you'll need to pass a "_method=delete" parameter to that route

Check out the rails guide on routing for more information:

Colin Law

unread,
Jan 20, 2012, 8:14:44 AM1/20/12
to rubyonra...@googlegroups.com

Also do not pass the user name but the id.

Colin

Loganathan Sellapa

unread,
Jan 20, 2012, 8:18:06 AM1/20/12
to rubyonra...@googlegroups.com
Hi Tim,

I already tried with the get method too. but no luck.

regards,
Loganathan


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/jAtXSzkQk9sJ.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Loganathan Sellapa

unread,
Jan 20, 2012, 8:18:56 AM1/20/12
to rubyonra...@googlegroups.com
Hi Colin

That was an api call, so we cannot change the url.

regards,
Loganathan





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.

Rob Biedenharn

unread,
Jan 20, 2012, 3:05:14 PM1/20/12
to rubyonra...@googlegroups.com
On Jan 20, 2012, at 7:38 AM, Loganathan Sellapa wrote:

Hi All,

I am having routes like below to delete/list an user.

map.connect 'developer/:user_name/delete',:controller=>"developers",:action=>"delete",:method=>:delete

You probably need to keep the '.' from being treated as a separator (like for a format):

:requirements => { :user_name => /.*/ }

-Rob

Mukesh Singh

unread,
Jan 20, 2012, 3:15:49 PM1/20/12
to rubyonra...@googlegroups.com
 constraints (:version  => /[0-9]{1}(?:.[0-9]{1,2})/) do
   match 'ws/:api_version => 'api#create'
 end

This route will match to 'ws/1.23" and you will have params[:version] == "1.23"

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.



--
Regards
Mukesh Paras Singh

Loganathan Sellapa

unread,
Jan 22, 2012, 7:22:23 AM1/22/12
to rubyonra...@googlegroups.com
I solved the problem by adding ActionController::Routing::SEPARATORS =  %w( / ; , ? ) in my routes.rb file,  but an warning message is displaying as below

config/routes.rb:12: warning: already initialized constant SEPARATORS


Want to know whether this warning will be an issue on future?

regards,
Loganathan
Reply all
Reply to author
Forward
0 new messages