
Untitled
By: a guest on
Jun 4th, 2012 | syntax:
None | size: 0.80 KB | hits: 13 | expires: Never
class Practice < ActiveRecord::Base
attr_accessible :name, :tax_id, :location_ids, :employee_ids, :system_ids
has_and_belongs_to_many :employees
has_and_belongs_to_many :locations
has_many :implementations
has_many :systems, :through => :implementations
# attr_accessor :system_ids
# after_save :update_systems
#after_save callback to handle system_ids
# def update_systems
# unless system_ids.nil?
# self.implementations.each do |m|
# m.destroy unless system_ids.include?(m.system_id.to_s)
# system_ids.delete(m.system_id.to_s)
# end
# system_ids.each do |g|
# self.implementations.create(:system_id => g) unless g.blank?
# end
# reload
# self.system_ids = nil
# end
# end
end