From 95a067a4def20a641a7e58c3b70747dd309244be Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Wed, 3 Sep 2014 12:48:09 +0900 Subject: [PATCH] Compare user_id's rather than user objects. --- app/models/agent.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/agent.rb b/app/models/agent.rb index db062e25..7109c02d 100644 --- a/app/models/agent.rb +++ b/app/models/agent.rb @@ -226,19 +226,19 @@ class Agent < ActiveRecord::Base private def sources_are_owned - errors.add(:sources, "must be owned by you") unless sources.all? {|s| s.user == user } + errors.add(:sources, "must be owned by you") unless sources.all? {|s| s.user_id == user_id } end def controllers_are_owned - errors.add(:controllers, "must be owned by you") unless controllers.all? {|s| s.user == user } + errors.add(:controllers, "must be owned by you") unless controllers.all? {|s| s.user_id == user_id } end def control_targets_are_owned - errors.add(:control_targets, "must be owned by you") unless control_targets.all? {|s| s.user == user } + errors.add(:control_targets, "must be owned by you") unless control_targets.all? {|s| s.user_id == user_id } end def scenarios_are_owned - errors.add(:scenarios, "must be owned by you") unless scenarios.all? {|s| s.user == user } + errors.add(:scenarios, "must be owned by you") unless scenarios.all? {|s| s.user_id == user_id } end def validate_schedule