studium nlink added

This commit is contained in:
Andreas Stephanides
2014-04-05 12:46:32 +02:00
parent b73f456f45
commit 4c9a3c8999
3 changed files with 8 additions and 3 deletions

View File

@@ -29,7 +29,8 @@
class Studium < ActiveRecord::Base
attr_accessible :desc, :name,:abkuerzung, :typ, :zahl, :semester, :picture, :picture_cache, :qualifikation,:struktur, :jobmoeglichkeiten
has_many :modulgruppen, inverse_of: :studium, :class_name => "Modulgruppe", :dependent => :destroy
scope :search, ->(query) {where("name like ? or studien.desc like ?", "%#{query}%", "%#{query}%")}
has_many :semester, :dependent => :destroy
validates :abkuerzung, :length=>{:maximum=>5}, :format=>{:with=>/^[a-zA-z]{0,5}$/}
validates :typ, :inclusion => {:in => ["Bachelor","Master"] }
@@ -40,7 +41,11 @@ class Studium < ActiveRecord::Base
def title_context
return self.abkuerzung.to_s.strip.empty? ? self.name : self.abkuerzung
end
has_many :nlinks, as: :link
def title
self.name
end
def batch_add_semester
# Semester automatisch zu Studien hinzufügen
if self.typ == "Bachelor"