Skip to content

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

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

1 participant

@bcardarella

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 is happening on both Rails 3.2.x an Rails 4.0.beta.1

@bcardarella

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
Something went wrong with that request. Please try again.