studium +picture new Layout

This commit is contained in:
Andreas Stephanides
2013-09-30 21:18:04 +02:00
parent 5c4bc925e6
commit 2c91a8db7e
4 changed files with 38 additions and 21 deletions

View File

@@ -27,13 +27,14 @@
# created_at :datetime not null
# updated_at :datetime not null
class Studium < ActiveRecord::Base
attr_accessible :desc, :name,:abkuerzung, :typ, :zahl, :semester
attr_accessible :desc, :name,:abkuerzung, :typ, :zahl, :semester, :picture, :picture_cache
has_many :modulgruppen, inverse_of: :studium, :class_name => "Modulgruppe", :dependent => :destroy
has_many :semester, :dependent => :destroy
validates :abkuerzung, :length=>{:maximum=>5}, :format=>{:with=>/^[a-zA-z]{0,5}$/}
validates :typ, :inclusion => {:in => ["Bachelor","Master"] }
validates :name, :uniqueness => true, :presence=>true
validates :zahl, :presence=>true, :format=>{:with=>/^0(33|66)[0-9]{3}$/}, :uniqueness => true
mount_uploader :picture, PictureUploader
translates :desc,:shortdesc, :versioning =>true,:fallbacks_for_empty_translations => true
def title_context
return self.abkuerzung.to_s.strip.empty? ? self.name : self.abkuerzung