javascript - Evaluate instance variable (defined in controller), from within a test.js.erb view -
how can evaluate instance variable within javascript view (for utilize ajax process)?
i conditional evaluation (in test.js.erb file) of instance variable defined in controller method.
controller method:
def test @var = 100 end
.js view:
if (<%= @var=100 %>) { alert("var: " + <%= @var %>); } else { alert("failed"); }
do need build entire conditional check within erb tags?
if (<%= @var %> === 100 ) {...}
javascript ruby-on-rails ruby-on-rails-3
No comments:
Post a Comment