Skip to content

Instantly share code, notes, and snippets.

@cannikin cannikin/rails_version.rb
Last active Feb 16, 2018

Embed
What would you like to do?
Two different forms of `include` in Ruby, only one of which works as expected
class BustedInclude
include ActiveModel::Validations, ActiveModel::Validations::Callbacks
before_validation { puts 'Callback!' }
end
# outputs only `true`
instance = BustedInclude.new
instance.valid?
class WorkingInclude
include ActiveModel::Validations
include ActiveModel::Validations::Callbacks
before_validation { puts 'Callback!' }
end
# outputs "Callback!" and then `true`
instance = WorkingInclude.new
instance.valid?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.