I have a code like this in my app/assets/javascripts/sample.js.erb
file.
var user_signed_in = <%= user_signed_in? %>;
if(user_signed_in){
// run code here
}
By the looks of it, with the .js.erb
file extension. This should work. I am able to use the user_signed_in?
in the view that uses this JS file. So why?
Try to make something like this
<% if current_user %>
<%= link_to "Add New Event",new_event_path %>
<% end %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.