Strong Parameters requires whitelisting of Action Controller parameters by default. In Ruby on Rails this means the developer will have to make a choice about which Active Model attributes are eligible for mass assignment. Strong parameters have been included in Rails 4 by default.
Questions tagged [strong-parameters]
956 questions
0
votes
2 answers
accepts_nested_attributes_for creating duplicates
accepts_nested_attributes_for creating duplicates
Model
class Article < ActiveRecord::Base
has_many :article_collections
accepts_nested_attributes_for :article_collections, :allow_destroy => true, reject_if: :all_blank
end
class…

Kanna
- 990
- 1
- 11
- 30
0
votes
1 answer
ForbiddenAttributesError on one-field form
I'm struggling with a Forbidden attributes error in a form that I've been working on. I tried removing all fields but one and am still getting the error so I'm really baffled.
Below is the one-field version of the form that's throwing the error and…

neanderslob
- 2,633
- 6
- 40
- 82
0
votes
1 answer
Rails strong parameters
I want to register this params to permit params in rails 4.
I have params like this.
"items"=>{"roles"=>{"1"=>{"menus"=>{"1"=>["true"]}}, "2"=>{"menus"=>{"1"=>["true"]}}}}
How should I change into permit params.
Thanks all.

akbarbin
- 4,985
- 1
- 28
- 31
0
votes
2 answers
With Nested Resources in routes.rb with custom to_param, how can Strong Parameters allow created/update to permit?
I can't find something that'll lead in the right direction. Everyone else's similar issues with nested resources seems to resolve around accepts_nested_attributes_for… which I'm not trying to do. I'm not trying to save children from the parent, I'm…

Turgs
- 1,729
- 1
- 20
- 49
0
votes
2 answers
Rails 4, Strong Parameters, Unpermitted parameters on fields belonging to associated model
This is my first try at using models with associations with Rails 4 and for some reason I'm not able to get at the parameters POST'ed in due to a "Unpermitted parameters" error. I have tried to permit the associated fields several different ways…

lps
- 1,403
- 16
- 28
0
votes
2 answers
Rails 4, nested forms, ActiveModel::ForbiddenAttributesError
I need to create revisions for products, so I have to move editable information in different table
I created nested form, but having troubles saving data: ActiveModel::ForbiddenAttributesError
As I understand, the problem is because of the naming,…
user846437
0
votes
1 answer
Rails 4 strong params formatting with multiple keys
I working a service that takes in any number of custom attributes and serializes it into a hash.
So it would look something like this:
custom_contacts: {"address_book"=>
[{"contact_list"=>"user_data",
"contacts"=>[{"name"=>"user_data",…

Charles
- 379
- 2
- 14
0
votes
1 answer
Rails Strong Params - Unknown Range of Numbers
I have a survey with many answers that I'm trying to pass through Strong Params. The problem is that surveys all have a different amount of answers (from 1..200).
Each answer is being passed to params like "answers" => {1: "Answer", 2: "Answer2", 4:…

Jackson Cunningham
- 4,973
- 3
- 30
- 80
0
votes
2 answers
Rails 4 permit any keys in the hash
I pass a params like this
{
"utf8" => true,
"supply" => {
"items" => { 111 => 112, 89 => 10},
"another_params" => "something"
}
}
My supply_params are:
params.fetch(:supply, {}).permit(:another_params, items: {})
But I get an…

Alex Antonov
- 14,134
- 7
- 65
- 142
0
votes
2 answers
Rails: How do I upload Paperclip image attachment to a DB from an unrelated controller + Strong params requirement
Help Request
How do I upload image attachment to from an unrelated controller + Strong params requirements?
Background
I have one controller, Cars. I have two models Car and Garage.
Cars controller creates a Garage object based on a user's…

captain awesome
- 359
- 1
- 3
- 18
0
votes
0 answers
Strong parameters in rails 3
I'm adding strong parameters to a Rails 3.2 project. It works fine with the models I want to protect. But it seems to affect other models/controllers. For example, serialization and ransack search parameter.
It seems because strong parameters…

xiangxin
- 409
- 6
- 18
0
votes
2 answers
strong_parameters in rails for multiple keys
I want to access three keys from params.
Say my params is:
params = {
'product_id' => 11,
'category' => {
'name' => 'Pet',
'sub_categories' => {5 => 'Name1', 7 => 'Name2'} ## **UPDATE**
…

Indyarocks
- 643
- 1
- 6
- 26
0
votes
1 answer
rails controller test failing non-deterministicly wrt state leak (I think)
I have a standard rest controller (with load_and_authorize_resource) for which I have the following strong params allowed:
def subscription_params
params.require(:subscription).permit(:email,:confirmed)
end
update action:
def update
…

Camden Narzt
- 2,271
- 1
- 23
- 42
0
votes
1 answer
strong_params removing id of accepts_nested_attributes_for models
I have the follow strong_params statement:
def product_grid_params
params.require(:product_grid).permit(:name,
product_grid_locations_attributes: [:id, :grid_index, :item_id, :item_type, :short_name, :long_name]
).merge({ venue_id:…

nullnullnull
- 8,039
- 12
- 55
- 107
0
votes
1 answer
Updating User password & email in separate forms but in same view
My goal is to create a profile page where the (logged in) user can choose to either update their email or their password (in separate forms so not both at the same time) without navigating away from the page.
Updating one's email is as simple as…

michael
- 167
- 5
- 23