Reputation: 26008
My model:
class MyModel < ActiveRecord::Base
before_save [:method1!, :method2!]
#..........
private
def method1!
puts 'method1'
end
def method2!
puts 'method2'
end
end
The methods method1
and method2
aren't not called for some reason when I save a model. Is there any error in my code?
Upvotes: 0
Views: 270
Reputation: 224
Just modify the model
class MyModel < ActiveRecord::Base
before_save :method1!, :method2!
#..........
private
def method1!
puts 'method1'
end
def method2!
puts 'method2'
end
end
I think it will help you.
Thanks.
Upvotes: 2
Reputation: 95
Try this: before_save do method1! end
private def method1! puts "method1!" end
Upvotes: 1