vigetlabs / active_admin_associations

This extends ActiveAdmin to allow for better editing of associations.
MIT License
119 stars 55 forks source link

Accessing current_admin_user in form #6

Closed mvoltolina closed 12 years ago

mvoltolina commented 12 years ago

Hi,

first of all thanks for your great contribution.

I am trying to display form fields based on CanCan with Rolify roles. Using the standard ActiveAdmin Form it works. using the active_association_form it does not.

My code:

f.input :sub_domain if current_admin_user.has_role? :super_admin

The error:

ActionView::Template::Error (undefined local variable or method `current_admin_user' for #ActiveAdmin::ResourceDSL:0xb4e8bc64): 1: <%= admin_form_for resource %> 2: 3: <%- if resource.persisted? && active_admin_config.form_associations.present? -%> 4: <%- active_admin_config.form_associations.each do |association| -%>

Any help would be appreciated.

Mario

mvoltolina commented 12 years ago

Never mind. I passed it as:

form :partial => "admin/shared/form", :locals => {:current_admin_user => current_admin_user}

brianjlandau commented 12 years ago

Glad you're liking it and happy to see you figured out your issue yourself!