I’m stuck in a Ruby on Rails tutorial at this point. I went through the has_secure_password class definition and I cant figure out in which part of the application is the password= method being called? I didn’t call it explicitly anywhere in our tutorial but the when I enter:
User.create{blah blah}
into the Rails console it automatically encrypts the password and adds it to the password_digest column!
I’ve been unable to Google this because of the = sign in the method name, so please help me out here.
Your relevant line is:
When ActiveRecord model classes receives
neworcreatewith an options hash, they transform the hash keys into method names and call#{method_name}=on the newly generated model.This allows for the controller pattern (or anti-pattern depending on your view)