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 19 |
# File 'lib/active_admin/reform/resource_controller/data_access.rb', line 16 def apply_decorations(resource) resource = super(resource) apply_form(resource) end |
#assign_attributes(resource, attributes) ⇒ ActiveRecord::Base, Reform::Form
24 25 26 27 28 29 30 31 |
# File 'lib/active_admin/reform/resource_controller/data_access.rb', line 24 def assign_attributes(resource, attributes) if resource.is_a?(::Reform::Form) resource.validate(*attributes) unless action_name == 'new' resource else super(resource, attributes) end end |
#save_resource(object) ⇒ void
This method returns an undefined value.
Calls all the appropriate callbacks and then saves the new resource.
38 39 40 41 42 43 44 |
# File 'lib/active_admin/reform/resource_controller/data_access.rb', line 38 def save_resource(object) if resource.is_a?(::Reform::Form) super unless object.errors.any? else super end end |