Guest User

Untitled

a guest
May 27th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. ## SrIndex Model belongs_to JobbookIndex through jobbook_index_id
  2. class SrIndex < ActiveRecord::Base
  3. belongs_to :jobbook_index
  4. attr_accessor :job_details
  5.  
  6. def validate
  7. if JobbookIndex.validate_job(job_details)
  8. self.jobbook_index_id = job_details
  9. else
  10. errors.add("Not a valid job")
  11. end
  12. end
  13.  
  14. end
  15.  
  16. ## JobbookIndex model has_many SrIndex along with other models using this field, I'd like to duplicate this method in multiple call backs
  17. class JobbookIndex < ActiveRecord::Base
  18. has_many :sr_indices
  19.  
  20. def self.invalidate_job(id)
  21. query = find_by_id(id)
  22.  
  23. if query.nil?
  24. false
  25. else
  26. true
  27. end
  28. end
  29.  
  30.  
  31. end
Add Comment
Please, Sign In to add comment