let's say you have @user = {'name'=>'steve'} in the controller
now your html page can display <p> <% =@user ['name']%> </p>
now lets say that you want to have access to @user in your .js file; add thisThing and the url for your tag <p id="thisThing" data-url="<% =@user %>" > <% =@user ['name']%> </p>
in your .js file var userInfo = $('#thisThing').data('url')
now you got userInfo in your .js (in line)
source share