-2

Hello I tried To use attr_protected on Rails 4 but I couldn't. It's say attr_protected is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add protected_attributes to your Gemfile to use old one.

What can I do know ?

attr_protected :project_id
Murat KAYA
  • 23
  • 7

2 Answers2

3

You really should consider using strong parameters instead. Otherwise, you'll run into a mess later with your mass assignment rules.

But, if you insist, add this to your Gemfile:

gem "protected_attributes", "~> 1.0.7"

And run Bundler:

bundle install
Chris Peters
  • 17,918
  • 6
  • 49
  • 65
0

Start to use strong parameters (recommended) or move back to protected attributes as suggested.

peresleguine
  • 2,343
  • 2
  • 31
  • 34
  • ActiveModel::ForbiddenAttributesError in RolesController#create [at]role = project.roles.new(params[:role]) I'm still taking error – Murat KAYA Mar 20 '14 at 10:44
  • @MuratKAYA you should spend some time to study the subject. Basically you need to assign params like this: `@role = project.roles.build(role_params)` and define private method `role_params` in a controller with permissible list: `params.require(:role).permit(:role_attribute_1, :role_attribute_2)`. Take a look at example here: http://guides.rubyonrails.org/action_controller_overview.html#strong-parameters. – peresleguine Mar 20 '14 at 11:11