ruby on rails - DRY-ing up ActiveAdmin -
i've got multiple resources in activeadmin installation share quite lot of same traits, like:
- the same or similar scopes
- equal or similar controller methods (action_methods, example)
- similar attributes (with code blocks) in show action
- similar attributes (with code blocks) in edit action
what best way avoid duplicating functionality across different resources?
i have set decorators avoid duplicating functionality in index view, i'm not sure if (and how?) used in other cases.
you need extend dsl monkey patch:
module activeadmin # class register blocks evaluated. class resourcedsl < dsl def your_custom_method attr #common code end end end
now can use your_custom_method in registered resource file.
https://github.com/activeadmin/activeadmin/blob/master/lib/active_admin/resource_dsl.rb
Comments
Post a Comment