Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

permitted_params - rails4 and inherited_resources

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 :(

like image 955
Alexey Poimtsev Avatar asked May 04 '13 08:05

Alexey Poimtsev


2 Answers

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.

like image 100
CupraR_On_Rails Avatar answered Oct 07 '22 02:10

CupraR_On_Rails


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'
like image 40
William Herry Avatar answered Oct 07 '22 03:10

William Herry