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

有帮助吗?

解决方案

The accepted solution (in comments) was using - instead of _ and replace - to _ in the controller.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top