erichmenge/signed_form

feature request:

Closed this issue · 10 comments

Integrate with Active Admin on Rails 4 so that AA forms "just work" Seems like the only solution presently is to add

def permitted_params 
   params.permit!
end

To your Application Controller. This seems somehow wrong and the concept of signed_forms plays well here.

I'll try to take a look at it this weekend.

On Jun 27, 2013, at 12:12 PM, Michael Lang notifications@github.com wrote:

Integrate with Active Admin on Rails 4 so that AA forms "just work" Seems like the only solution presently is to add

def permitted_params
params.permit!
end
To your Application Controller. This seems somehow wrong and the concept of signed_forms plays well here.


Reply to this email directly or view it on GitHub.

I just did that with the following patch:

module ActiveAdmin
  class BaseController
    include SignedForm::ActionController::PermitSignedParams
  end
  module ViewHelpers
    module FormHelper
      alias_method :orig_active_admin_form_for, :active_admin_form_for

      def active_admin_form_for(resource, options = {}, &block)
        options[:signed] = true
        orig_active_admin_form_for resource, options, &block
      end
    end
  end
end

If someone gives me a hint where to put that, I can post a pull request.

@cschramm I think having a set of application/other_system specific plugins would be the best answer here. signed_form-active_admin or the like would make it easy to handle, but feel free to get creative.

active_admin-signed_form, whatever you'd like. It should pull in signed_form as a dependency, and then provide the module and any other nice things you feel are worth adding.

What I would suggest pull requesting here is an edit to the README.md adding a list of integration gems and putting yours right at the tippy top of that list for everyone to see.

@erichmenge, what do you think of this? Is it worth keeping signed_gem a bit leaner, or would you like it to include features like this in the distribution?

I think a separate gem is a little overkill for those few lines, but if that's the consensus I'm willing to start and maintain it.

If we integrate it directly, I would require the user to manually include the integration instead of always loading it. I'd suggest putting the code in lib/signed_form/active_admin.rb and instruct the user to add require 'signed_form/active_admin' to an initializer to use it.

I think part of why I'd prefer it in a separate gem is because gems don't need to be large, and mostly because I have a pretty passionate dislike for active admin. That being said, I'd rather see a module that gets included into ActiveAdmin::ViewHelpers::FormHelper that defines #active_admin_form_for and calls super over an alias method approach.

If you pull request something with some reasonable tests that can be easily maintained without adding very much maintenance overhead with respect towards the active admin side of things, I'd be willing to give it a good look over and merge it unless @erichmenge wants to put it in a separate gem.

In general I prefer a separate gem as well. But I also agree with @cschramm that for such little code a separate gem seems like over kill. It would be easy to remove later if the code became more complicated.

+1 for separate. Support for rails plugins should come from a plugin IMHO.

OK, I'll separate it then and just add a note to the README.

Super awesome @cschramm fixed this!

rockin'