diff --git a/app/models/neuigkeit.rb b/app/models/neuigkeit.rb index 560cb92..2ae2c67 100755 --- a/app/models/neuigkeit.rb +++ b/app/models/neuigkeit.rb @@ -28,7 +28,7 @@ class Neuigkeit < ActiveRecord::Base scope :unpublished, -> {where("datum >= ? OR datum IS NULL", Date.today)} scope :public, ->{includes(:rubrik).where("rubriken.public"=>:true)} scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")} - LINKTYPES=["Thema", "Gallery", "Lva"] + LINKTYPES=["Thema", "Gallery", "Lva","Studium"] accepts_nested_attributes_for :calentries, :allow_destroy=>true , :reject_if=> lambda{|a| a[:start].blank?} before_validation :sanitize has_many :nlinks diff --git a/app/models/nlink.rb b/app/models/nlink.rb index c3130f9..368cc4e 100644 --- a/app/models/nlink.rb +++ b/app/models/nlink.rb @@ -4,7 +4,7 @@ class Nlink < ActiveRecord::Base belongs_to :link, :polymorphic=>true validates :neuigkeit, :presence=>true validates :link, :presence=>true -validates :link_id, :uniqueness=>{:scope=>[:neuigkeit_id]} + validates :link_id, :uniqueness=>{:scope=>[:neuigkeit_id]} end diff --git a/app/models/studium.rb b/app/models/studium.rb index 4f2f73e..a869d37 100755 --- a/app/models/studium.rb +++ b/app/models/studium.rb @@ -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"