Prevent user_ids lookup for role assets (not needed in frontend - Customer role will have almost any user id in it).
This commit is contained in:
parent
ba4567d813
commit
b7c0ddb90f
2 changed files with 17 additions and 1 deletions
|
@ -37,7 +37,7 @@ class ApplicationModel < ActiveRecord::Base
|
||||||
|
|
||||||
# create instance accessor
|
# create instance accessor
|
||||||
class << self
|
class << self
|
||||||
attr_accessor :activity_stream_support_config, :history_support_config, :search_index_support_config
|
attr_accessor :activity_stream_support_config, :history_support_config, :search_index_support_config, :attributes_with_associations_support_config
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :history_changes_last_done
|
attr_accessor :history_changes_last_done
|
||||||
|
@ -197,6 +197,7 @@ returns
|
||||||
attributes = self.attributes
|
attributes = self.attributes
|
||||||
self.class.reflect_on_all_associations.map { |assoc|
|
self.class.reflect_on_all_associations.map { |assoc|
|
||||||
real_ids = assoc.name.to_s[0, assoc.name.to_s.length - 1] + '_ids'
|
real_ids = assoc.name.to_s[0, assoc.name.to_s.length - 1] + '_ids'
|
||||||
|
next if self.class.attributes_with_associations_support_config && self.class.attributes_with_associations_support_config[:ignore][real_ids.to_sym] == true
|
||||||
next if !respond_to?(real_ids)
|
next if !respond_to?(real_ids)
|
||||||
attributes[real_ids] = send(real_ids)
|
attributes[real_ids] = send(real_ids)
|
||||||
}
|
}
|
||||||
|
@ -1327,6 +1328,20 @@ delete object history, will be executed automatically
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
|
serve methode to configure and attributes_with_associations support for this model
|
||||||
|
|
||||||
|
class Model < ApplicationModel
|
||||||
|
attributes_with_associations(ignore: { user_ids: => true })
|
||||||
|
end
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
def self.attributes_with_associations_support(data = {})
|
||||||
|
@attributes_with_associations_support_config = data
|
||||||
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
|
|
||||||
get list of attachments of this object
|
get list of attachments of this object
|
||||||
|
|
||||||
item = Model.find(123)
|
item = Model.find(123)
|
||||||
|
|
|
@ -9,6 +9,7 @@ class Role < ApplicationModel
|
||||||
before_create :validate_permissions
|
before_create :validate_permissions
|
||||||
before_update :validate_permissions
|
before_update :validate_permissions
|
||||||
|
|
||||||
|
attributes_with_associations_support ignore: { user_ids: true }
|
||||||
activity_stream_support permission: 'admin.role'
|
activity_stream_support permission: 'admin.role'
|
||||||
notify_clients_support
|
notify_clients_support
|
||||||
latest_change_support
|
latest_change_support
|
||||||
|
|
Loading…
Reference in a new issue