Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
2 answers
124 views

How to deserialize boolean params.permit value correctly to make sure it's boolean in Rails

There are params to permit: { "string_value": "value", "boolean_value": "true/false", "other_value": "blabla" } I need to convert ...
unnamed_road's user avatar
0 votes
2 answers
52 views

Rails: How to error when two strong parameters are sent together at the same time? Allow one of them only

Let's say I accept two different parameters on input: param1 and param2 but I don't allow them to be passed together. How do I error in that case? I need to notify the client they are sending ...
unnamed_road's user avatar
1 vote
1 answer
585 views

Rails attr_accessor defined attributes outside of strong params hash in controller?

Consider the following User model schema: create_table "users", id: :serial, force: :cascade do |t| t.string "fname" t.string "lname" end Model: class User < ...
pinkfloyd90's user avatar
0 votes
0 answers
311 views

How to add a new item to strong parameters with Rails?

Rails version: 5 I want to post a new item named urls to rails from frontend. export function printPosts(params) { const endpoint = `v1/posts/print` return http.post(endpoint, params).then(({ data ...
iooi's user avatar
  • 523
0 votes
1 answer
346 views

How to permit an array json with Rails?

For json { "version":"1", "configs":[ { "title":"Good", "body":"Body" }, { &...
iooi's user avatar
  • 523
1 vote
0 answers
833 views

How to handle unpermitted parameters in Rails

Given the following PUT request domain/api/v1/conversations/id { "group_id": "123456", "foo": "bar" } If I use: params.permit(:group_id) I would have an ...
Samuel's user avatar
  • 269
2 votes
0 answers
550 views

How to dynamically set 'name' attribute of a simple form input

I am using Simple Form in a Rails application in which a FormsController controller was defined as follow : class FormsController < ApplicationController def index @forms = Form.all end ...
ogs's user avatar
  • 1,229
1 vote
1 answer
400 views

Forms and Strong Parameters Identification Hash

I defined the following strong params and new method in a controller named FormsController. Use case is that the user can create one form which includes several fields. class FormsController < ...
ogs's user avatar
  • 1,229
0 votes
1 answer
457 views

How should I permit parameters for idempotent actions (e.g. index, edit and show)?

In my view file I implemented AJAX that makes a idempotent GET request to the following rendered URL: resources_path(:param1 => "value1", :param2 => "value2", :param3 => "value3", :paramN =&...
Backo's user avatar
  • 18.8k
5 votes
1 answer
2k views

Rails: .require() without actually requiring it?

I'm trying to use... params.require(:subscriber).permit(:utm_source, :utm_medium, :utm_campaign, :utm_term, :utm_content) The problem is there are rare occasions where I want to do: Subscriber.new(...
Tallboy's user avatar
  • 13.4k
0 votes
0 answers
40 views

Finding all the views including the same action

There is a controller action with an unprotected mass assignment, where I want to implement strong parameters in. In case that there are multiple views sending parameters to this action, how can I ...
blu's user avatar
  • 167
1 vote
1 answer
1k views

Rails 5, access params hash

I think I'm loosing it here ... so I have a params hash, that I want to use in a controller: Parameters: {"utf8"=>"✓", "_method"=>"patch", "authenticity_token"=>"etcetc", "scan"=> {"1"=>{"...
BerryGJS's user avatar
  • 119
6 votes
2 answers
6k views

Strong Params: params.permit returns Unpermitted parameters despite whitelist

UsersProfileController has strong params that looks like so: def user_profile_params params.permit(:age, :relations) # yes, I am not requiring user_profile. Just permitting ...
Uzzar's user avatar
  • 703
0 votes
1 answer
2k views

Handle parameter missing exception in rails

I have a category and product model, where the product model belongs to a category. Currently I have a link on the category show view which takes the user to a new product form and sets the category ...
Isengrim's user avatar
5 votes
4 answers
11k views

How to permit hash with * key => values?

I want to create an object with strong params that can accept dynamic hash keys. This is my code, Quiz.create(quiz_params) def quiz_params params.require(:quiz).permit(:user_id, :percent, :grade, ...
Eric Chu's user avatar
  • 1,679
2 votes
2 answers
705 views

Rails 4: strong parameter with variable key hash

I need to be able to permit parameters that contain a hash with a variable key. I've looked at other solutions but none seem to work for me. The parameters are as follows: {"consult_stat"=>{"...
Jeremy Thomas's user avatar
0 votes
1 answer
35 views

Strong paramters and nested attributes/forms giving me grief

So I am having some problems with strong parameters and nested forms (suprise! Nobody's ever had that problem before lol) and I've been looking at several threads, trying different solutions but still ...
Hanky's user avatar
  • 1
0 votes
1 answer
1k views

Rails permit nested hash parameters

Here are my params: {"utf8"=>"✓", "authenticity_token"=>"g0mNoBytyd0m4oBGjeG3274gkE5kyE3aPbsgtqz3Nk4=", "commit"=>"Save changes", "plan_date"=>{"24"=>{"recipe_id"=>"12"}, "25"=>{"...
james's user avatar
  • 4,029
0 votes
2 answers
211 views

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....
marcamillion's user avatar
  • 33.7k
0 votes
1 answer
97 views

How rails interprets params hash, strict parameters

At first, when I was creating posts, the user id was nil. Originally my post_params were just :content & :category. It wasn't until I added :user_id that I was finally able to get post.user....
Kohl's user avatar
  • 87
1 vote
1 answer
12k views

ActionController::ParameterMissing param is missing or the value is empty

I can't solve this problem. When I try to use "Chatroom#new" method, I I got this error, ActionController::ParameterMissing param is missing or the value is empty . below codes are the ...
user3674902's user avatar
18 votes
1 answer
12k views

rails strong parameter not accepting array of hashes

I have a group controller which accepts array of hashes as parameter for POST request for create action def create response = Group.create(current_user_id, group_params) render json: ...
Gagan's user avatar
  • 4,368
1 vote
1 answer
295 views

How to permit nested hash parameters with the StrongParameters gem?

I am using Ruby on Rails 4.1 and I would like to permit the following incoming parameters by using the StrongParameters gem: # Parameters: { "my_key" => { "one" => { "0" => { "...
Backo's user avatar
  • 18.8k
1 vote
1 answer
468 views

Number_field_tag to create unique records for each item/ quantity

I'm using a number_field_tag to allow users to indicate how many of a given item they have. For each of these items then, a new record should be created in the model. Default quantity for all item ...
james's user avatar
  • 4,029
0 votes
2 answers
50 views

Validating parameters to create a class, parameters created in the controller arn't being added.

I create a class that takes two input parameters from the user, these input parameters are then used to create five others, the problem is that the five others don't show up when I check my validated ...
NNNNNNNNNNDelicious's user avatar
1 vote
2 answers
3k views

Rails & strong_parameters 'required parameter missing'

I'm working on creating 'retweet'(restream) functionality for one of my projects, but I keep running into this error: Required parameter missing: restream I'm not sure what I'm missing here. Here's ...
iamdhunt's user avatar
  • 453
1 vote
1 answer
104 views

Rails 4: using both strong params and "normal" params

I'm kind of new to Rails 4. Right now, I'm using both strong params and "normal" params. By normal params I mean the params[:key] which is not permitted. For example: Strong params: def ...
dkonayuki's user avatar
  • 742
0 votes
1 answer
652 views

rails 4 strong params error: param not found

Im trying to accomplish some functionality in the update method of my model. However, I am getting the following errors which seem to be due to the strong parameter convention introduced in rails 4. ...
banditKing's user avatar
  • 9,579
2 votes
0 answers
73 views

Rubyctaculous Gem in Rails 4

On the offset - I am new to Rails, and struggling.. I am trying to implement https://github.com/basgys/rubyctaculous to my pins upload... I have a scaffold where the image (or pin) is uploaded to ...
owenob1's user avatar
  • 19
2 votes
1 answer
172 views

How to find out which parameter is not permitted

I'm getting the error ActiveModel::ForbiddenAttributesError, but I can't find out which parameter is causing the problem. Does anyone know how I can find out which parameter causes to raise the error ...
user971938's user avatar
0 votes
1 answer
2k views

Rails4: ForbiddenAttributesError on nested parent's params

I'm still trying to wrap my head around Strong Parameters in Rails 4. I'm getting an ActiveModel::ForbiddenAttributesError when trying to submit a form with params for another model that it belongs_to....
Meltemi's user avatar
  • 38.3k
2 votes
2 answers
959 views

can't permit custom params with strong parameters

I want to permit nested custom parameters but am not sure how to access them. These are my params: params=> {"utf8"=>"✓", "authenticity_token"=>"...", "tracking"=>{"installation"...
crispychicken's user avatar
0 votes
1 answer
286 views

lynda course on ruby - rails 4 incompatible

So I'm doing the lynda.com rails course. Since the course was recorded for rails 3.1 and I'm now on Rails 4 and they are now enforcing strong_parameters . I added the subject_params definition to ...
Davi Trindade's user avatar
1 vote
1 answer
3k views

Save record in rails 4.0 using params hash

I'm trying to create a new record in rails using the form_for helper method. I think the params hash is blank because I keep getting blank errors when I submit the form. This is my form: <% ...
brownie3003's user avatar