Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Shamim's Profile

GitHub User: sjahandideh

Comments by Shamim

Avatar

Hi Ryan, Thanks for this great episode. In your submit code:

ruby
def submit(params)
    ....
    if valid?
      @user.password = new_password
      @user.save!
      true
    else
      false
    end
 end

I think you better use @user.save instead of save!. The reason is that your submit method can then only return true or false:

ruby
if valid?
  @user.password = new_password
  @user.save
else
  false
end

As someone who reads your code, i dont expect to see user validation errors on password submit method.

Avatar

Thank you for the useful episodes Ryan.

I found it cleaner to use haml_coffee_assets as the template engine as you don't need to write your Html code using javascript. and you can simply use coffeescript inside your haml templates :)