Module: StudySubjectLanguages
- Included in:
- StudySubject
- Defined in:
- app/models/study_subject_languages.rb
Overview
Simply extracted some code to clean up model. I’d like to do this to all of the really big classes but let’s see how this goes first.
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/models/study_subject_languages.rb', line 7 def self.included(base) # Must delay the calls to these ActiveRecord methods # or it will raise many "undefined method"s. base.class_eval do has_many :subject_languages has_many :languages, :through => :subject_languages accepts_nested_attributes_for :subject_languages, :allow_destroy => true, :reject_if => proc{|attributes| attributes['language_id'].blank? } end # class_eval end |