It seems a stupid question, but there are no way to achieve this
With Rails 4.2.5.
in a remote call to the controller,
def update
# ... save ...
@notice="S'han trovat errors"
# automatically renders update.js.erb
end
in update.js.erb
alert('<%=(@notice)%>');
What I've tried:
1)In the controller:
@notice="S'han trovat errors".html_safe
2)another proof, in js.erb:
alert('<%=raw(@notice)%>');
In both cases, when javascript function alert()
is executed, it hangs without any message in terminal neither in browser console ¿?
3)I have tried too:
alert('<%=escape_javascript(@notice)%>');
But doesn't work, shows "S'han trobat..."
Of course, if I show in index.html.erb
, @notice , the result is correct (S'han trobat..)
I don't know how to pass from controller to js.erb a " ' " character in a string instance variable to be shown
Thanks