Rafael wrote in post #1110688:
> Per this:
> 
http://guides.rubyonrails.org/active_record_validations_callbacks.html#available-callbacks
>
> before_validation only occurs/runs on create and update
>

Thank you. I found an explanation. Just to pass :on => save will include 
both:

class Person < ActiveRecord::Base
  # it will be possible to update email with a duplicated value
  validates :email, :uniqueness => true, :on => :create

  # it will be possible to create the record with a non-numerical age
  validates :age, :numericality => true, :on => :update

  # the default (validates on both create and update)
  validates :name, :presence => true, :on => :save
end

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/a01a262b328bad655c496b3a85946ee8%40ruby-forum.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to