Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## SrIndex Model belongs_to JobbookIndex through jobbook_index_id
- class SrIndex < ActiveRecord::Base
- belongs_to :jobbook_index
- attr_accessor :job_details
- def validate
- if JobbookIndex.validate_job(job_details)
- self.jobbook_index_id = job_details
- else
- errors.add("Not a valid job")
- end
- end
- end
- ## JobbookIndex model has_many SrIndex along with other models using this field, I'd like to duplicate this method in multiple call backs
- class JobbookIndex < ActiveRecord::Base
- has_many :sr_indices
- def self.invalidate_job(id)
- query = find_by_id(id)
- if query.nil?
- false
- else
- true
- end
- end
- end
Add Comment
Please, Sign In to add comment