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

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -