Forum: Ruby on Rails create_without_callbacks

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Alex Y. (Guest)
on 2006-02-20 10:32
(Received via mailing list)
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,
Mark Reginald J. (Guest)
on 2006-02-20 13:09
(Received via mailing list)
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.
This topic is locked and can not be replied to.