I am using Rails 3.1.0 and I would like to “require” a parameter-string in a router-URL the proper way. That is, I have a token parameter that must be checked on performing a HTTP POST request so to update user information:
my_site_name/user/1?token=12345abcdr
I am planning to add a constrain in the router.rb file so to “require” that token. Is it advisable? Should I proceed like that? If so, how can I state the related router?
Maybe I could state/use a “named router” passing two parameters this way:
confirm_user_url(@user, token)
As far as I understood, you are trying to make token parameter required when ‘performing a HTTP POST request so to update user information’ (by the way, should’t it be a PUT request, if you are UPDATING?). If so, why not use a custom constraint? In your
routes.rb:Hope it helps.