Skip to content

Instantly share code, notes, and snippets.

@paulsonkoly
Last active December 11, 2019 10:47
Show Gist options
  • Save paulsonkoly/e57b3e9c98e0aa7180b6c32fc61c9938 to your computer and use it in GitHub Desktop.
Save paulsonkoly/e57b3e9c98e0aa7180b6c32fc61c9938 to your computer and use it in GitHub Desktop.
validator
require 'active_support'
require 'active_model'
class Form
include ActiveModel::Validations
include ActiveModel::Attributes
attribute :blah
validates :blah, numericality: true
end
f = Form.new
f.blah = 'a'
f.valid? # => false
f._validators[:blah].object_id # => 47297490130120
f2 = Form.new
f2._validators[:blah].object_id # => 47297490130120
Form._validators[:blah].object_id # => 47297490130120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment