In rails 3.1 app I have a controller UsersController with ‘show’ action.
<% content_for(:head) do %>
<% end %>
And I have this in myscript.js.erb
alert(<%= @user.name %>);
@user is being assigned by a controller and it works just ok in
show.html.erb, but in myscript.js.erb I get nil as @user and exception
What’s my error here? How to get around this?
I googled, but all suggestions I found were about rendering partial and
using :local option to pass a variable to it.
Is this the only option?
I’m asking because I suspect I miss something. It would look really
for @user being accessible in js.erb loaded through