You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bigfive edited this page Jul 23, 2012
·
5 revisions
To define a resource inside of an engine, use the following technique:
# lib/my_engine/admin/articles.rbifdefined?(ActiveAdmin)ActiveAdmin.registerArticledo# customize your resource hereendend
Note that it is very important to keep the admin/*.rb definitions out of the Rails' eager load paths to avoid loading these files more than once. If they get loaded multiple times, you are likely to experience weird problems with duplicated filters in the filter forms, duplicate action_item buttons, broken belongs_to definitions, etc. And that will happen only in production (ie. when config.cache_classes = true).
For example, your engine's lib/ folder is a good choice in contrast to its app/ folder (if any). That's because app/ is in the eager load paths and all *.rb files there get recursively loaded by Rails when config.cache_classes = true (usually the case in production environments). However, ActiveAdmin takes care to load these files too and that will be the reason for them to get loaded more than once.