I have two models on rails. The first is the patient model
class Patient
attr_accessible :name, :age, :sex, :female_attributes
has_one :female, dependent => :destroy
accepts_nested_attributes_for :female, allow_destroy => true
end
The second model holds extra info for female patients
class Female
belongs_to :patient
attr_accessible :patiend_id, :pregrnant_now: :childbirths
end
Note: I didn't create the db schema and i can't change it.
So my question is: how can i reject the female object from being saved in the db by checking the :sex attribute in the patient object?
I tried
reject_if => lambda { |a| a['sex'].to_i == 0 ) }
but it didn't work. ( sex is an integer and gets 0 for Male and 1 for Female )
Any thoughts??