Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class EmergencyContact < ActiveRecord::Base
- attr_accessible :full_name, :relationship, :mobile_phone, :student_id
- belongs_to :student
- validates :full_name, :presence => true
- validates :relationship, :presence => true
- end
- Student Name: _____________
- Emergency Contacts
- ------------------------------------------
- | Name | Relationship |
- ------------------------------------------
- | | |
- ------------------------------------------
- | | |
- ------------------------------------------
- | | |
- ------------------------------------------
- class Student < ActiveRecord::Base
- has_many :emergency_contacts
- accepts_nested_attributes_for :emergency_contacts,
- :reject_if => lambda { |a| a[:full_name].blank? }
- end
- proc { |attributes|
- attributes.delete :_destroy
- attributes.reject { |key, value| value.blank? }.empty?
- }
- accepts_nested_attributes_for :emergency_contacts, :reject_if => :all_blank
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement