Module: ActiveAdmin::Reform::ResourceController::DataAccess
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_admin/reform/resource_controller/data_access.rb
Overview
Overrides ActiveAdmin’ templates method to wrap model into Reform::Form
Instance Method Summary collapse
- #apply_decorations(_resource) ⇒ ActiveRecord::Base, Reform::Form
- #assign_attributes(resource, attributes) ⇒ ActiveRecord::Base, Reform::Form
-
#save_resource(object) ⇒ void
Calls all the appropriate callbacks and then saves the new resource.
Instance Method Details
#apply_decorations(_resource) ⇒ ActiveRecord::Base, Reform::Form
16 17 18 |
# File 'lib/active_admin/reform/resource_controller/data_access.rb', line 16 def apply_decorations(_resource) apply_form(super) end |
#assign_attributes(resource, attributes) ⇒ ActiveRecord::Base, Reform::Form
23 24 25 26 27 28 29 30 |
# File 'lib/active_admin/reform/resource_controller/data_access.rb', line 23 def assign_attributes(resource, attributes) if resource.is_a?(::Reform::Form) resource.validate(*attributes) unless %w(new edit).include?(action_name) resource else super end end |
#save_resource(object) ⇒ void
This method returns an undefined value.
Calls all the appropriate callbacks and then saves the new resource.
37 38 39 40 41 42 43 |
# File 'lib/active_admin/reform/resource_controller/data_access.rb', line 37 def save_resource(object) if resource.is_a?(::Reform::Form) super unless object.errors.any? else super end end |