From 2b429681d045180136a1d4a5fb69497e4f7d927d Mon Sep 17 00:00:00 2001 From: Guillaume DOTT Date: Tue, 23 Sep 2014 14:47:23 +0200 Subject: [PATCH] Correct bug with association moderation `TheModerator::Model` is not included in every `ActiveRecord` model so it has to be included in association models if it is not when moderating associations. --- lib/the_moderator/model.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/the_moderator/model.rb b/lib/the_moderator/model.rb index 82ada13..d1d5084 100644 --- a/lib/the_moderator/model.rb +++ b/lib/the_moderator/model.rb @@ -69,6 +69,7 @@ module TheModerator assoc_fields = data[:data] assoc_fields_display = data[:data_display] else + objects.class.send(:include, TheModerator::Model) unless objects.respond_to?(:moderation_data) data = objects.moderation_data(*moderated_attributes) assoc_fields = data[:data].merge(id: objects.id) unless data[:data].empty? assoc_fields_display = data[:data_display] unless data[:data_display].empty? @@ -83,6 +84,7 @@ module TheModerator tab = [] objects.each do |resource| + resource.class.send(:include, TheModerator::Model) unless resource.respond_to?(:moderation_data) data = resource.moderation_data(*moderated_attributes) assoc_fields[resource.id] = data[:data].merge(id: resource.id) unless data[:data].empty?