Class: Subject
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Subject
- Defined in:
- app/models/subject.rb
Instance Attribute Summary collapse
-
#classification_id ⇒ Object
Returns the value of attribute classification_id.
-
#subject_heading_type_id ⇒ Object
Returns the value of attribute subject_heading_type_id.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#classification_id ⇒ Object
Returns the value of attribute classification_id.
3 4 5 |
# File 'app/models/subject.rb', line 3 def classification_id @classification_id end |
#subject_heading_type_id ⇒ Object
Returns the value of attribute subject_heading_type_id.
3 4 5 |
# File 'app/models/subject.rb', line 3 def subject_heading_type_id @subject_heading_type_id end |
Class Method Details
.import_subjects(subject_lists, subject_transcriptions = nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/models/subject.rb', line 46 def self.import_subjects(subject_lists, subject_transcriptions = nil) return [] if subject_lists.blank? subjects = subject_lists.gsub(';', ';').split(/;/) transcriptions = [] if subject_transcriptions.present? transcriptions = subject_transcriptions.gsub(';', ';').split(/;/) transcriptions = transcriptions.uniq.compact end list = [] subjects.compact.uniq.each_with_index do |s, i| s = s.to_s.exstrip_with_full_size_space next if s == "" subject = Subject.where(:term => s).first term_transcription = transcriptions[i].exstrip_with_full_size_space rescue nil unless subject # TODO: Subject typeの設定 subject = Subject.new( :term => s, :term_transcription => term_transcription, :subject_type_id => 1, ) subject.required_role = Role.where(:name => 'Guest').first subject.save else if term_transcription subject.term_transcription = term_transcription subject.save end end list << subject end list end |
Instance Method Details
#subject_heading_type ⇒ Object
42 43 44 |
# File 'app/models/subject.rb', line 42 def subject_heading_type self.subject_heading_types.first end |