In my application_controller.
def ensure_service_agreement
if current_user.agrees_to_service == true
@tos = true
else
@tos = false
end
end
I have the following code in my application.js file.
var tos = "<%= @tos %>";
if(tos == false){
$(".new-session-home").on('click', function (){
$('.booking.modal')
.modal('show');
})
}else{
$(".new-session-home").on('click', function (){
$('.tos.modal')
.modal('show');
})
}
The javascript doesn't seem to register the var tos. When I set the first if statement to either true or false, I get the second modal (the tos modal)
If I set tos = 4 and then check for that number, it works as it should so I know the problem is with the rails instance variable.
How can I get the JS to understand my instance variable?