Is possible to check boolean value by JS?
In Rails 4 app i need to implement bootstrap modal when user comes for first time and accept the terms.
I'm trying to do something like this:
application.html.haml
...
= content_tag :body, data: { accept_terms: current_user.accept_terms? } do
...
current_user.accept_terms? - just instance method returns true or false
main.js.coffee
...
$(document).on 'page:change', ->
return unless $('body').data('accept-terms')
$('.terms-modal').modal 'show'
...
Yep, something like that could work. That should print out true or false in the data attribute (you can inspect the html to verify) and sure give you back a Javascript boolean you can use when you query for it.