forked from bofh/fetsite
Upgraded to Rails 4
This commit is contained in:
@@ -13,9 +13,12 @@ class Meeting < ActiveRecord::Base
|
||||
# Belongs to a news article, that is usually the Announcement of that meeting
|
||||
belongs_to :neuigkeit, touch: true
|
||||
# has one protocol of type Document, which is of typ=10=protocol
|
||||
has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent
|
||||
#has_one :test_ol, :class_name=>'Document', -> { where(:typ => 10) }
|
||||
|
||||
has_one :protocol, -> { where(:typ => 10) }, :class_name=>'Document', :as=>:parent
|
||||
|
||||
# has one agenda of type Document
|
||||
has_one :agenda , :as=>:parent,:conditions=>{:typ=>11}, :class_name=>'Document'
|
||||
has_one :agenda, -> { where :typ=>11 } , :as=>:parent, :class_name=>'Document'
|
||||
# has one calentry which contains the date and time of this meeting
|
||||
has_one :calentry, as: :object, :dependent=> :destroy
|
||||
# has one calendar through the meetingtyp, thus each meeting is put into a calendar
|
||||
@@ -24,14 +27,14 @@ class Meeting < ActiveRecord::Base
|
||||
has_one :rubrik, :through=>:meetingtyp
|
||||
|
||||
# scope upcomming only contains meetings in the future and 1 hour into the past
|
||||
scope :upcomming, includes(:calentry).where("calentries.start>?",1.hour.ago)
|
||||
default_scope includes(:calentry).order("calentries.start").reverse_order
|
||||
scope :upcomming, -> {includes(:calentry).where("calentries.start>?",1.hour.ago)}
|
||||
default_scope -> { includes(:calentry).order("calentries.start").reverse_order}
|
||||
accepts_nested_attributes_for :calentry
|
||||
|
||||
# Each meeting is required to have a parent otherwise it will not be shown anywhere on the website
|
||||
validate :parent, :presence=>true
|
||||
validates :parent, :presence=>true
|
||||
# Each meeting needs a calendar entry
|
||||
validate :calentry, :presence=>true
|
||||
validates :calentry, :presence=>true
|
||||
|
||||
|
||||
# before each validation fix the calendar entry such that it is always
|
||||
|
||||
Reference in New Issue
Block a user