Migrate AR finder/query methods in models

pull/6827/head
Alex Coles 9 years ago
parent 75d95c3a55
commit b6aa9c0987
  1. 4
      app/models/meeting.rb
  2. 2
      app/models/meeting_content.rb
  3. 2
      app/models/meeting_participant.rb

@ -69,7 +69,7 @@ class Meeting < ActiveRecord::Base
after_initialize :set_initial_values
User.before_destroy do |user|
Meeting.update_all ['author_id = ?', DeletedUser.first.id], ['author_id = ?', user.id]
Meeting.where(['author_id = ?', user.id]).update_all ['author_id = ?', DeletedUser.first.id]
end
def start_date
@ -116,7 +116,7 @@ class Meeting < ActiveRecord::Base
changeable_participants = participants.select(&:invited).collect(&:user)
changeable_participants = changeable_participants + participants.select(&:attended).collect(&:user)
changeable_participants = changeable_participants + \
project.users.all(include: { memberships: [:roles, :project] }).select { |u| self.visible?(u) }
project.users.includes(memberships: [:roles, :project]).select { |u| self.visible?(u) }
changeable_participants.uniq(&:id)
end

@ -36,7 +36,7 @@ class MeetingContent < ActiveRecord::Base
url: Proc.new { |o| { controller: '/meetings', action: 'show', id: o.meeting } }
User.before_destroy do |user|
MeetingContent.update_all ['author_id = ?', DeletedUser.first], ['author_id = ?', user.id]
MeetingContent.where(['author_id = ?', user.id]).update_all ['author_id = ?', DeletedUser.first]
end
def editable?

@ -28,7 +28,7 @@ class MeetingParticipant < ActiveRecord::Base
attr_accessible :email, :name, :invited, :attended, :user, :user_id, :meeting
User.before_destroy do |user|
MeetingParticipant.update_all ['user_id = ?', DeletedUser.first], ['user_id = ?', user.id]
MeetingParticipant.where(['user_id = ?', user.id]).update_all ['user_id = ?', DeletedUser.first]
end
def name

Loading…
Cancel
Save