Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActionController::UnpermittedParameters - found unpermitted parameters: commentable_type, commentable_id #34

Closed
dept42 opened this issue Dec 11, 2014 · 4 comments

Comments

@dept42
Copy link

dept42 commented Dec 11, 2014

I was receiving this error, with a fresh install of 2.2.2 on rails 4.1.5:

ActionController::UnpermittedParameters - found unpermitted parameters: commentable_type, commentable_id:
  actionpack (4.1.5) lib/action_controller/metal/strong_parameters.rb:377:in `unpermitted_parameters!'
  actionpack (4.1.5) lib/action_controller/metal/strong_parameters.rb:270:in `permit'
  the_comments (2.2.2) app/controllers/concerns/controller.rb:168:in `comment_params'
  the_comments (2.2.2) app/controllers/concerns/controller.rb:113:in `create'

I was able to easily fix by adding this to my own comments_controller:

  def comment_params
    params
    .require(:comment)
    .permit(:title, :contacts, :raw_content, :parent_id, :commentable_type, :commentable_id)
    .merge(denormalized_fields)
    .merge(request_data_for_comment)
    .merge(tolerance_time: params[:tolerance_time].to_i)
    .merge(user: current_user, view_token: comments_view_token)
  end

..but I don't understand how it ever could have worked by default. Is this a bug, or is something wrong with my installation?

@the-teacher
Copy link
Member

Hello!
You should to remove additional params here. Because :commentable_type, :commentable_id used into another place:

https://github.com/the-teacher/the_comments/blob/master/app/controllers/concerns/the_comments/controller.rb#L138

Right now I can't understend why you have this error. Try to install code from master version 2.3.0
For my projects gem works fine.

Btw, I worrking on version 3. You can learn new version in branch v3.0

@alexpchin
Copy link

In the view, have you edited @post

<%= render partial: 'the_comments/tree', locals: { commentable: @post, comments_tree: @comments } %>

?

@the-teacher
Copy link
Member

btw: secret project: https://github.com/TheComments

@the-teacher
Copy link
Member

out of date. sorry

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

No branches or pull requests

3 participants