module AdminIt::ActiveRecordData::SingleContext
Protected Instance Methods
load_entity(identity: nil)
click to toggle source
# File lib/admin_it/data/active_record/single_context.rb, line 7 def load_entity(identity: nil) identity ||= controller.params[:id] entity = entity_class.find(identity) controller.authorize(entity, "#{name}?") if AdminIt::Env.pundit? if child? fields(scope: :relation) .select { |f| f.assoc.klass == parent.entity_class } .each do |f| if f.assoc.collection? entity.send(f.name) << parent.entity else entity.send("#{f.name}=", parent.entity) end end end entity end