Migrate model has_many conditions to lambda

pull/6827/head
Alex Coles 9 years ago
parent 6b8bcc4f37
commit 53b04b7f90
  1. 2
      app/models/meeting.rb
  2. 2
      lib/open_project/meeting/patches/project_patch.rb

@ -25,7 +25,7 @@ class Meeting < ActiveRecord::Base
belongs_to :author, class_name: 'User', foreign_key: 'author_id' belongs_to :author, class_name: 'User', foreign_key: 'author_id'
has_one :agenda, dependent: :destroy, class_name: 'MeetingAgenda' has_one :agenda, dependent: :destroy, class_name: 'MeetingAgenda'
has_one :minutes, dependent: :destroy, class_name: 'MeetingMinutes' has_one :minutes, dependent: :destroy, class_name: 'MeetingMinutes'
has_many :contents, class_name: 'MeetingContent', readonly: true has_many :contents, -> { readonly }, class_name: 'MeetingContent'
has_many :participants, dependent: :destroy, class_name: 'MeetingParticipant' has_many :participants, dependent: :destroy, class_name: 'MeetingParticipant'
default_scope order("#{Meeting.table_name}.start_time DESC") default_scope order("#{Meeting.table_name}.start_time DESC")

@ -23,7 +23,7 @@ module OpenProject::Meeting
module ProjectPatch module ProjectPatch
def self.included(receiver) def self.included(receiver)
receiver.class_eval do receiver.class_eval do
has_many :meetings, include: [:author], dependent: :destroy has_many :meetings, -> { includes(:author) }, dependent: :destroy
end end
end end
end end

Loading…
Cancel
Save