active_admin_editor icon indicating copy to clipboard operation
active_admin_editor copied to clipboard

Issue with Strong Parameters??

Open rhnorment opened this issue 9 years ago • 6 comments

I love this gem and have successfully used it for several years. For some reason, I just started getting this error:

ActionController::UnpermittedParameters in Admin::PostsController#create

I tried adding :_wysithml5_mode as a permitted param, but that did not work.

I'm running:

activeadmin 1.0.0.pre2 Rails 4.2.4 Ruby 2.2.3

Thanks in advance.

rhnorment avatar Feb 28 '16 16:02 rhnorment

What parameters are you sending?

I'm loading this up in a similar configuration as we speak. I'll touch back with what I find.

joshmn avatar Mar 14 '16 21:03 joshmn

Reporting back:

I can't reproduce this out of the box. Here are the parameters I'm sending,

Parameters: {"utf8"=>"✓", "authenticity_token"=>"YaNEO9yK5082BhkcPZvwnxhffhUZjyV9+RgoFs5j8mwA08EdGMKEXEz7gMX8Ws62BmXdacDajv6KQ0l4TOqEwQ==", "news_item"=>{"title"=>"cool man bro", "content"=>"<p>asdf</p>", "donators"=>"1"}, "_wysihtml5_mode"=>"1", "commit"=>"Create News item"}

I don't think you'll need to pass _wysihtml5_mode as a param unless I'm missing something very obvious.

joshmn avatar Mar 14 '16 21:03 joshmn

Sorry for the delayed reply. I am sending the following:

{"utf8"=>"✓",
 "authenticity_token"=>"96WVpfxuZyqHvWlkNUuznYoyS/zal1xy2nrTM6SEi4yqJILK6UWKKCuTYXGWmmCH4UYUAUPwzB4ZUlh3WoqmSg==",
 "post"=>{"author"=>"test author",
 "title"=>"test title",
 "body"=>"<p>test rich text editor</p>"},
 "_wysihtml5_mode"=>"1",
 "commit"=>"Create Post"}

I get this error:

  ActiveSupport::Notifications.instrument(name, keys: unpermitted_keys)
          when :raise
            raise ActionController::UnpermittedParameters.new(unpermitted_keys)
          end
        end
      end

rhnorment avatar Mar 26 '16 14:03 rhnorment

+1 on this. Works perfectly on one of my apps but error just started appearing on the other.

perjonsson avatar Apr 01 '16 08:04 perjonsson

Anyone have another solution for this? Another HTML editor for AA? This is a blocker for me.

rhnorment avatar May 05 '16 14:05 rhnorment

This workaround works.

module ActiveAdmin
  class ResourceDSL < DSL
    def permit_params(*args, &block)
      resource_sym = config.resource_name.singular.to_sym
      controller do
        define_method :permitted_params do
          params.permit :_method, :_wysihtml5_mode, :authenticity_token, :commit, :id, :utf8,
                        resource_sym =>
                        block ? instance_exec(&block) : args
        end
      end
    end
  end
end

rhnorment avatar Jun 07 '16 21:06 rhnorment