Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top