Question

in my users_helper i have the following method :

users_helper.rb

def status(user)
   if user.active?
      capture_haml do
         haml_tag 'span.status' do 
            haml_concat "active"
         end
      end
   else
      capture_haml do
         haml_tag 'span.status' do 
            haml_concat "inactive"
         end
      end
   end
end

then i have a remote link to change the user's status, so if the status is changed i want to replace my span.status with the result returned by status method which is in my users_helper

change_status.js.haml

- unless @user.errors.any? 
   plain:
      $("span.status").html("#{status(@user)}");

but this seem not working, when i check the error with firebug i have this :

Inconsistent indentation: 1 tab used for indentation, but the rest of the document was indented using 2 spaces.
Was it helpful?

Solution

In change_status.js.haml, you have indented the code with two spaces throughout the document but at one place you used tab.

Make sure that indentation is uniform in your Haml file. Don't mix-match, use either two spaces throughout the document or tab throughout the document. Choose one and stick to it.

EDIT

Also, escape the results of status method using escape_javascript.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top