Create_without_callbacks


#1

Hi all,

I don’t think I’m being stupid here, but would be glad of correction.
I’m trying to future-proof early migrations, so rather than use
AR::Base.create, I want to use AR::Callbacks.create_without_callbacks.
It looks like I should be able to, from the way it’s aliased in
activerecord/callbacks.rb. When I try to, though, I get an “undefined
method `create_without_callbacks’ for Fragment:Class” error. Is there
some good reason for this I’ve missed? Is there a different way of
getting AR instances saved in migrations without getting lifecycle
callbacks called?

Thanks,


#2

Alex Y. wrote:

I don’t think I’m being stupid here, but would be glad of correction.
I’m trying to future-proof early migrations, so rather than use
AR::Base.create, I want to use AR::Callbacks.create_without_callbacks.
It looks like I should be able to, from the way it’s aliased in
activerecord/callbacks.rb. When I try to, though, I get an “undefined
method `create_without_callbacks’ for Fragment:Class” error. Is there
some good reason for this I’ve missed? Is there a different way of
getting AR instances saved in migrations without getting lifecycle
callbacks called?

This appears to be a bug in ActiveRecord. One fix is to change the
“private” above the definition of create_or_update in base.rb to
“protected”.


We develop, watch us RoR, in numbers too big to ignore.