public
Last active

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
class Lawyer < ActiveRecord::Base
 
def extracted?
!source.blank?
end
 
with_options :unless => :extracted? do |lawyer|
lawyer.validates_presence_of :oab,
:phones,
:address,
:day_of_birth,
:email
lawyer.validates_associated :phones,
:address,
:nextels,
:cities
end
 
end
 
l = Lawyer.new
l.source = "whatever"
l.valid? # returns true
l.address = Address.new
l.valid? # returns false
l.save validate:false
l.reload
l.valid? # returns true

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.