Closed mockdeep closed 8 years ago
Oops, I'm conflating a couple of things. That error is a known issue with active record.
But the other piece still stands, since I can't add before_save
callbacks into with_model
.
Please provide minimal failing example code.
On Wednesday, September 30, 2015, Robert Fletcher notifications@github.com wrote:
Oops, I'm conflating a couple of things. That error is a known issue https://github.com/rails/rails/issues/718 with active record.
But the other piece still stands, since I can't add before_save callbacks into with_model.
— Reply to this email directly or view it on GitHub https://github.com/Casecommons/with_model/issues/23#issuecomment-144511533 .
(Sent via iPhone)
with_model :Dummy do
after_save -> { puts 'whatevs' }
table(&:timestamps)
end
results in:
undefined method `after_save' for #<WithModel::Model::DSL:0x0000000a6a7728> (NoMethodError)
Did you mean to do:
with_model :Dummy do
model do
after_save -> { puts 'whatevs' }
end
table(&:timestamps)
end
Also the error with the code you give is different than your original error (though you did mention that that particular error was the result of an ActiveRecord bug, not the issue with with_model).
Ah, you are correct. My mistake.
I'm trying to write a dummy model to test that callbacks are used properly, but
with_model
throws an error:I don't know if it's digging too deep into re-implementing the underlying details of ActiveRecord, but it would be nice to be able to use
with_model
to test callbacks as well.