Questions tagged [strong-parameters]

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.

956 questions
0
votes
1 answer

Are these 2 different ways of writing nested attributes in strong params?

I am working with nested attributes and strong params and I’ve seen two different ways of nesting attributes in strong params. Take this example: class Post < ActiveRecord::Base has_many :comments accepts_nested_attributes, :comments class Comments…
0
votes
1 answer

Creating multiple objects with one http request

I have an rails app with json api. So far I can create single objects via POST request. It's fairly simple: def create customer = Customer.new(customer_params) if customer.save render json: customer, status: 201 else …
potofski
  • 101
  • 1
  • 3
  • 12
0
votes
0 answers

Rails 4 unpermitted parameters for multi tag input

I have working code that uses select2 to accept multiple tags into the one input field. I used this solution to permit my parameter as: params.require(:computer_service).permit( {:repairer_ids => []}) This works correctly. I recently set Rails to…
Marklar
  • 1,247
  • 4
  • 25
  • 48
0
votes
1 answer

Rails 4.1.8 "blog" posts not saving text or title when using strong parameters

I'm a long time lurker who's google-fu is failing him today. I've been learning to use Rails using a video series that was created before Rails 4 came out. As such, the lectures use the attr_accessibly mass assignments. I've been attempting to…
0
votes
2 answers

How to implement strong parameters in Rails 4

I'm having trouble implementing strong parameters, receiving the Undefined Method attr_accessible error locally. Could anyone explain what exactly I have done wrong here. users_controller.rb: class UsersController < ApplicationController def…
GCien
  • 2,221
  • 6
  • 30
  • 56
0
votes
2 answers

Why are user attributes unpermitted on invitations controller but no other user controller?

I am using Devise. When a user sends an invitation and the receiving user fills out their :first_name and :last_name fields, I get this message in my log: Started PUT "/users/invitation" for 127.0.0.1 at 2015-02-25 14:10:06 -0500 Processing by…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
0
votes
0 answers

Create action with delayed_job

In my controller I am trying to move my create method into a background process, as it takes too much time. I can't get it right. My option 1: First I went with creating a self method for my controller so it looked like this: def create …
0
votes
1 answer

Rails 4 mass assign array of objects

I want to mass assign array of objects in rails 4. How should I set strong parameters for this requirement? My Controller assignment code if a_params a_params.each do |param,index| a = A.new(param) end end My permit code def a_params …
MadNik
  • 7,713
  • 2
  • 37
  • 39
0
votes
1 answer

Rails way for creating an endpoint accepting multiple objects at once

I need to create an endpoint that accepts multiple objects at once. Example request (json body) below: { "obd_bluetooth_events" : [ { "car_id": 1, "obd_plugin_id": "1", "kind": "CONNECT", …
mmln
  • 2,104
  • 3
  • 24
  • 33
0
votes
0 answers

How do I explicitly whitelist the following parameters on my rails controller?

This is the hash on the request: {"a"=>{"foo"=>{"1"=>[{"bar"=>"1", "qaz"=>"80"}], "6"=>[{"bar"=>"1", "qaz"=>"80"}, {"bar"=>"1", "qaz"=>"84"}]}} I've been trying something like this without luck: params.require(:a).permit({foo: [:bar, :qaz]}) I get…
user177468
  • 225
  • 5
  • 18
0
votes
1 answer

Rails for Zombies Level 4 Exercise 3 (WITH Rails 4 Strong Parameters)

I am doing the above exercise on railsforzombies.org, and I simply cannot figure out why it keeps telling me I am not using strong parameters. I am using the examples shown in the video as a guide, but I keep getting the message: "Did not create a…
0
votes
2 answers

declare value for strong parameters

i have problem when i have to declare value for one of parameters in my permit and out of post form values . look at my code : class QuoteController < ApplicationController autocomplete :author, :name, :full => true autocomplete :Category,…
Pedram marandi
  • 1,474
  • 1
  • 19
  • 35
0
votes
1 answer

rails4 fail creating relation can't write unknown attribute

I have the following code db: create_table :parties do |t| t.integer :host_id t.integer :guests t.string :description end user: class User < ActiveRecord::Base has_many :host_parties, class_name: 'Party' end party: class Party <…
avital
  • 559
  • 1
  • 7
  • 19
0
votes
1 answer

How to permit custom params using strong parametes gem?

I am getting params as follows. {"utf8"=>"✓", "authenticity_token"=>"auth_token=", "js_data_entry"=>[{"data_entry"=>[{"name"=>"test_book22", "node_id"=>"65", "field_type"=>"Text", "options_attributes"=>[{"option_value"=>""}], "location"=>"Body",…
Can Can
  • 3,644
  • 5
  • 32
  • 56
0
votes
1 answer

Rails 4 strong parameters Unknown parameter error

Simple one-to-many relationship going on and getting a Unpermitted parameter in the server log. Cup 1----*> Contacts The params looks like Parameters: {"utf8"=>"✓", "authenticity_token"=>"Ay/wRwJTr4u5Vgu5oOrk7z4RC/OfeLJdN9WXuoyU7iQ=",…
H.Rabiee
  • 4,747
  • 3
  • 23
  • 35