ruby on rails - Indentation error using result of haml_tag inside js.haml template -
in users_helper have following method :
users_helper.rb
def status(user) if user.active? capture_haml haml_tag 'span.status' haml_concat "active" end end else capture_haml haml_tag 'span.status' haml_concat "inactive" end end end end then have remote link change user's status, if status changed want replace span.status result returned status method in users_helper
change_status.js.haml
- unless @user.errors.any? plain: $("span.status").html("#{status(@user)}"); but seem not working, when check error firebug have :
inconsistent indentation: 1 tab used indentation, rest of document indented using 2 spaces.
in change_status.js.haml, have indented code two spaces throughout document @ 1 place used tab.
make sure indentation uniform in haml file. don't mix-match, use either two spaces throughout document or tab throughout document. choose 1 , stick it.
edit
also, escape results of status method using escape_javascript.
Comments
Post a Comment