Question

The context is a bit complex, but basically, to get some nifty CSS3 effects to run, the requirement is to establish a link via an HTML onclick handler.

The problem lies in passing the locale. I haven't found any way to escape "#{params[:locale]" to append it to the derived path, in such a way that rails interprets it first, the builds the url.

<div class="view" onclick="location.href='/structures/3?locale=%Q#{params[:locale]}%Q'">
Was it helpful?

Solution

You are trying to access params which is rails inside a view html code. You need to put a rails tag . for ex smtin like dis :

<div class="view" onclick="location.href='/structures/3?locale=%Q<%= params[:wateva] %>%Q'">

This will make the link as /structures/3?locale=%Qparams_wateva_value%Q

Don't exactly know why you need the %Q at the start and the end.

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