Using Module#prepend on an ActiveRecord::Base class causes callbacks to go missing #10899

Closed
bcardarella opened this Issue Jun 10, 2013 · 2 comments

Comments

Projects
None yet
1 participant
@bcardarella
Contributor

bcardarella commented Jun 10, 2013

Run the following: (you must be using Ruby 2.0 obviously)

require 'active_record'

ActiveRecord::Base.establish_connection(
  :adapter => defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3',
  :database => ':memory:'
)

ActiveRecord::Base.connection.execute('CREATE TABLE users (id INTEGER PRIMARY KEY, email TEXT)')

module A; end

class User < ActiveRecord::Base
  prepend A
end

User.create

The last line will blow up with an error similar to _run__XXXXXXX__validation__callbacks cannot be found.

I tried tracing this one down but ActiveSupport::Callbacks is beyond me.

@bcardarella

This comment has been minimized.

Show comment
Hide comment
@bcardarella

bcardarella Jun 10, 2013

Contributor

This is happening on both Rails 3.2.x an Rails 4.0.beta.1

Contributor

bcardarella commented Jun 10, 2013

This is happening on both Rails 3.2.x an Rails 4.0.beta.1

@bcardarella

This comment has been minimized.

Show comment
Hide comment
@bcardarella

bcardarella Jun 10, 2013

Contributor

Nevermind, this looks like it was a bug in Ruby 2.0.0-p0 but was resolved in 2.0.0-p195

https://bugs.ruby-lang.org/issues/8005

Contributor

bcardarella commented Jun 10, 2013

Nevermind, this looks like it was a bug in Ruby 2.0.0-p0 but was resolved in 2.0.0-p195

https://bugs.ruby-lang.org/issues/8005

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment