diff options
Diffstat (limited to 'activemodel/examples/validations.rb')
-rw-r--r-- | activemodel/examples/validations.rb | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/activemodel/examples/validations.rb b/activemodel/examples/validations.rb deleted file mode 100644 index b8e74acd5e..0000000000 --- a/activemodel/examples/validations.rb +++ /dev/null @@ -1,30 +0,0 @@ -require File.expand_path('../../../load_paths', __FILE__) -require 'active_model' - -class Person - include ActiveModel::Conversion - include ActiveModel::Validations - - validates :name, presence: true - - attr_accessor :name - - def initialize(attributes = {}) - @name = attributes[:name] - end - - def persist - @persisted = true - end - - def persisted? - @persisted - end -end - -person1 = Person.new -p person1.valid? # => false -p person1.errors.messages # => {:name=>["can't be blank"]} - -person2 = Person.new(name: 'matz') -p person2.valid? # => true |