Reputation: 52357
I need to get access to params
inside following block:
ActiveAdmin.register Discussion, namespace: :dev_panel do
raise params.inspect
...
end
I need it exactly in there, not in controller
or inside action_item
whatsoever.
But I'am getting
undefined local variable or method
params
for ActiveAdmin::ResourceDSL
Does anyone know how do I do that?
My goal is to be able to define such two blocks in admin/discussions.rb
:
ActiveAdmin.register Discussion, namespace: :dev_panel do
belongs_to :my_active_submission, parent_class: ClientApplication
...
end
and
ActiveAdmin.register Discussion, namespace: :dev_panel do
belongs_to :lead_submission, parent_class: ClientApplication
...
end
The issue with that, is that AA only treats the latter block, and behaves as there is no previous one. My bet is that issue is with namespace - I can't define two blocks of same resource and namespace.
Upvotes: 0
Views: 1450
Reputation: 3073
It is technical not possible to access params at that place. The register block is only executed one at the loading and not per request.
Write down a full example, like you have access to params and we maybe find a other solution.
Upvotes: 1
Reputation: 3807
Did you try defining your Discussion with as: option? I have a model which needs to be used in a number of different context so I set up:
ActiveAdmin.register Discussion, as: 'ActiveDiscussion' do; end
ActiveAdmin.register Discussion, as: 'PoliticalDiscussion' do; end
Or you can sub-class Discussion as you needed
class ActiveDiscussion < Discussion; end
class PoliticalDiscussion < Discussion; end
And then register them to ActiveAdmin.
ActiveAdmin.register ActiveDiscussion do; end
ActiveAdmin.register PoliticalDiscussion do; end
Hope it helps.
Upvotes: 1