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.
master
Guillaume Dott 2014-09-23 14:47:23 +02:00
parent 168fc7b9db
commit 2b429681d0
1 changed files with 2 additions and 0 deletions

View File

@ -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?