I have a javascript function which takes rails value like
<body onload="myFunction(<%p%>)">
and I'm trying to pass a value coming from the controller like this
<% if logged_in? -%><%p= current_user.id %><% end -%> but here the p doesn't contain the value. this works if I put code like this
<body onload="myFunction(<%= current_user.id%>)">
<% if logged_in? -%><%= current_user.id %><% end -%>
But I need a further requirement, so another line like this should be add
<% if logged_out? -%><%p= current_user.id %><% end -%>
So if the user is logged out then the value p will passed to the javascript function. I know this is a small thing but don't know how to do it, I'm new to ror so please help and if you have tutorials to learn this point me too, so that can I save the time of both you and me in the future.