I have the following variable in my controller:
class MyController < ApplicationController
def my_method
@status = "status"
end
end
In my haml
view, I tried following, but it doesn't work (since it's using the default .erb syntax):
#app/views/mycontroller/me_method.html.haml
:javascript
alert(<%=raw @status %>)
How can I use the @status
variable inside my inline JavaScript?
You can use the simple "#{}" interpolation tags to use ruby variables with HAML.
Your code:
:javascript
alert(<%=raw @status %>)
Possible Solution:
:javascript
alert("#{@status}")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With