Why does `before_save` not work in Rails 4?

When I try u = User.new and then u.save , the before_save method before_save not start.

Here is my User model:

 class User < ActiveRecord::Base attr_accessor :password before_save :encrypt_password def encrypt_password puts "Its getting called" end end 

https://railsforum.com/topic/1741-rails-4-and-before-save-method/

+8
ruby ruby-on-rails ruby-on-rails-4
source share
1 answer

Callback methods must be either protected or private .

From here: http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html in the Types of callbacks section

+14
source share

All Articles