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 is
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 natural
for @user being accessible in js.erb loaded through
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ocxAmLujxpYJ.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to firstname.lastname@example.org.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.