The accepted solution (in comments) was using -
instead of _
and replace -
to _
in the controller.
RoR: How to retain underscore from URL parameters
-
04-10-2022 - |
Domanda
I am trying to get a parameter from the URL and subsequently call a function using that parameter. But the issue is that the parameter sometimes contains an _
character, which gets skipped and wrong parameter is passed to the function.
Say my url is localhost:3000/deal/diamond_deal
. I get the parameter as
q= params[:promo]
But on doing so, q is set to diamond deal
and not diamond_deal
. How can work around this issue, please can someone help?
Thanks
EDIT: 1. Route for the URl: match "/deal/:promo" => "deal#index", :as => "deal"
2. Rails version: Rails 3.1.10
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow