1

I am trying to trigger a bootstrap modal based on conditions about the current user. Essentially, to do anything in the page the user is accessing, they need to have created a hotel in the system. If they haven't, I want a modal to pop up with the creation form. Currently, I have:

 <%= unless current_user.hotels.exists? 
    "<script>
       $('#createhotelModal').modal('toggle') 
     </script>"
     end    
    %>

Which simply inserts the as text. Trying to next a <%= javascript_tag do %> command doesn't work with the controller throwing various errors. Is this the smart way to do it, or should I just create a completely separate page and use the controller to send people to the correct page?

1 Answer 1

2

Follow advice listed in this railscast

<%= javascript_tag do %>
  $('#createhotelModal').modal('toggle')
<% end %>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.