5

I've tried to use IR in rails4 app, but my code

class WorkspacesController < InheritedResources::Base

  private

  def permitted_params
    params.permit(:workspace => [:name, :owner_id])
  end
end

raises ActiveModel::ForbiddenAttributesError exception.

the same problem with following code

  def permitted_params
    params.permit(:name, :owner_id)
  end

Whats wrong with this code?

PS: i've tried following protip http://blog.josemarluedke.com/posts/inherited-resources-with-rails-4-and-strong-parameters but with 4.0rc1 it doesn't work :(

Alexey Poimtsev
  • 2,845
  • 3
  • 35
  • 63
  • Can you post the params? Have you tried params.require(:workspace).permit(:name, :owner_id)? – John May 06 '13 at 06:18
  • Is this the preferred solution for rails 4.0.0 final? I've checked the issue tracker but haven't seen any definitive approach on how to get rid of protected_attributes when using inherited_resources. – Preston Lee Jul 02 '13 at 21:39
  • This worked: http://joshcrews.com/blog/2013/09/05/getting-inherited-resources-gem-to-work-with-strong-parameters/ – odigity Apr 07 '14 at 00:50

2 Answers2

6

I had the same problem.

You need to put permitted_params method as public method in your controller class. It's NOT a private method.

I hope this help.

CupraR_On_Rails
  • 2,449
  • 1
  • 19
  • 24
2

I have meet this problem too, but seem not same as yours, just put how I resolve this in case some meet same problem with mine

replace Gemfile with this

gem 'inherited_resources', github: 'josevalim/inherited_resources'
William Herry
  • 1,430
  • 14
  • 26