0

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?

Ricardo Green
  • 968
  • 1
  • 10
  • 27

1 Answers1

0

Try to make something like this

<% if current_user  %>
  <%= link_to "Add New Event",new_event_path %>
<% end %>
nourza
  • 2,039
  • 2
  • 15
  • 28