module AdminIt::ActiveRecordData::SavableSingleContext

Protected Instance Methods

add_child_context(for_resource, context_class: :table) click to toggle source
# File lib/admin_it/data/active_record/single_context.rb, line 43
def add_child_context(for_resource, context_class: :table)
  child_resource = AdminIt.resources[for_resource]
  return nil if child_resource.nil?
  child_resource[context_class].new(self)
end
do_save_entity() click to toggle source
# File lib/admin_it/data/active_record/single_context.rb, line 30
def do_save_entity
  if AdminIt::Env.pundit?
    controller.authorize(entity, "#{self.class.save_action}?")
  end
  params = controller.params[resource.name]
  fields(scope: :writable).each do |field|
    next unless params.key?(field.name)
    next unless field.writable?
    field.write(entity, params[field.name])
  end
  controller.redirect_to_default if entity.save
end