Skip to content
This repository has been archived by the owner on Aug 1, 2018. It is now read-only.

Issue with Strong Parameters?? #68

Open
rhnorment opened this issue Feb 28, 2016 · 6 comments
Open

Issue with Strong Parameters?? #68

rhnorment opened this issue Feb 28, 2016 · 6 comments

Comments

@rhnorment
Copy link

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.

@joshmn
Copy link

joshmn commented Mar 14, 2016

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
Copy link

joshmn commented Mar 14, 2016

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.

@rhnorment
Copy link
Author

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

@perjonsson
Copy link

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

@rhnorment
Copy link
Author

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

@rhnorment
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants