Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 4th, 2012  |  syntax: None  |  size: 0.80 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class Practice < ActiveRecord::Base
  2.   attr_accessible :name, :tax_id, :location_ids, :employee_ids, :system_ids
  3.  
  4.   has_and_belongs_to_many :employees
  5.   has_and_belongs_to_many :locations
  6.  
  7.   has_many :implementations
  8.   has_many :systems, :through => :implementations
  9.  
  10. #  attr_accessor :system_ids
  11. #  after_save :update_systems
  12.  
  13.     #after_save callback to handle system_ids
  14. #    def update_systems
  15. #      unless system_ids.nil?
  16. #        self.implementations.each do |m|
  17. #          m.destroy unless system_ids.include?(m.system_id.to_s)
  18. #          system_ids.delete(m.system_id.to_s)
  19. #        end
  20. #        system_ids.each do |g|
  21. #          self.implementations.create(:system_id => g) unless g.blank?
  22. #        end
  23. #        reload
  24. #        self.system_ids = nil
  25. #      end
  26. #    end
  27.  
  28.  
  29.  
  30. end