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

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -