title: How to automatically remove Active Admin form inputs with Pundit permitted attributes?
body: <p>I have a Rails 4 app using Active Admin 1.0.0.pre1 in conjunction with pundit 0.3.0 for authorization which has worked flawlessly thus far, but I'm having trouble figuring out a good way automatically customize forms based on a user's role.</p>
  
  <p>Given these models:</p>
  
  <pre><code>ActiveAdmin.register AdminUser do
    permit_params do
      Pundit.policy(current_admin_user, resource).permitted_attributes
    end
  
    form do |f|
      f.inputs "Admin Details" do
        f.input :role, as: :select, collection: [:manager, :admin]
        f.input :email, as: :email
        f.input :password
        f.input :password_confirmation
      end
      f.actions
    end
  end
  
  class AdminUserPolicy &lt; ApplicationPolicy
    def permitted_attributes
      attributes = [:email, :password, :password_confirmation]
      attributes += [:role] if user.has_role? :super_admin
      attributes
    end
  end
  </code></pre>
  
  <p>I'd like for the <code>role</code> input to be automatically removed from the form.</p>
  
  <p>One option would be something along the lines of:</p>
  
  <pre><code>  permitted_attributes = Pundit.policy(current_admin_user, resource).permitted_attributes
  
    form do |f|
      f.inputs "Admin Details" do
        f.input :role if permitted_attributes.include? :role
        f.input :email
        f.input :password
        f.input :password_confirmation
      end
      f.actions
    end
  </code></pre>
  
  <p>but, that approach requires the developer to remember which attributes should be checked, seems prone to forgetfulness and isn't exactly DRY.  Perhaps, I am going about this the wrong way?  All suggestions welcome. </p>