diff --git a/app/models/thema.rb b/app/models/thema.rb index c11e5f7..c81f1d7 100644 --- a/app/models/thema.rb +++ b/app/models/thema.rb @@ -16,9 +16,10 @@ class Thema < ActiveRecord::Base has_many :attachments belongs_to :themengruppe, :foreign_key => "themengruppe_id" has_one :gremium + has_many :nlinks, as: :link validates :themengruppe, :presence => true validates :title, :presence => true + validates :text, :presence => true scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")} - has_many :nlinks, as: :link translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true end diff --git a/app/models/themengruppe.rb b/app/models/themengruppe.rb index 5a6b973..ca42007 100644 --- a/app/models/themengruppe.rb +++ b/app/models/themengruppe.rb @@ -10,12 +10,14 @@ class Themengruppe < ActiveRecord::Base WORD_COUNT = 50 - attr_accessible :text, :title, :picture,:priority + attr_accessible :text, :title, :picture, :priority has_many :themen, class_name: 'Thema' has_many :fragen, through: :themen + mount_uploader :picture, PictureUploader validates :title, :presence => true + validates :text, :presence => true translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true end