Reputation: 1036
I have a number of shared DSL code in ActiveAdmin; I have looked into a number of ways to share the code, some of which included creating a module that I include in the resource and others that included, adding the path to the Active Admin initializers.
However, I've found that nothing is working. I think there should be a simple way to just share similar code across the resources -- and by code it is really DSL including Arbre and other domain specific language.
Here are the kinds of things I hope to share across the board:
index do
selectable_column
id_column
column :email
column :current_sign_in_at
column :sign_in_count
column :created_at
actions
end
filter :email
filter :current_sign_in_at
filter :sign_in_count
filter :created_at
menu false
scope :active
scope :inactive
scope :all_items, :default => true
member_action :toggle_activate, method: :get do
...
end
Any help will be greatly appreciated. I definitely want to be a DRY coder.
Upvotes: 0
Views: 229
Reputation: 6029
How about including the following mixin to your classes:
module Foo
def self.included(base)
base.class_eval do
# your shared code here
end
end
end
Upvotes: 1