Skip to main content
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
89 views

What could cause Rails to structure params as flat rather than hierarchical?

I have a strange error in my rails application that is being triggered by someone probably doing something they shouldn't be doing. But I can't figure out what they might be doing and thus how to ...
Tyler's user avatar
  • 151
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
0 votes
1 answer
72 views

Rails: how to sanitize nested object to save to JSONB column?

Given these strong parameters in a Rails controller: def user_params params.require(:user).permit(details: [{ group: %i[type value] }]) end How do I sanitize the details array before it's persisted ...
t56k's user avatar
  • 6,981
0 votes
0 answers
61 views

How to deserialize a non standard JSON request in Rails? (non-JSONAPI)

In a Rails app, I'm receiving a JSON request to track a Order model. I need to save all this to the DB. I'm not sure how to handle this input into the controller. The JSON request body is in this ...
DariusP's user avatar
  • 513
1 vote
1 answer
248 views

Rails strong params, how to allow empty params?

I have set these strong params: def my_model_params params.require(:my_model).permit(:field) end But sometimes the form is sent empty and I get this error: param is missing or the value is empty: ...
fguillen's user avatar
  • 38.6k
0 votes
1 answer
233 views

How to Send Multiple Select Values as an Array in Rails Params?

I have a complex form in a Rails application where I'm using multiple instances of a template. Each template contains a dropdown for product variations. When the form is submitted, I want to send the ...
andgarzonmal's user avatar
0 votes
1 answer
871 views

How to prevent Unpermitted parameters

On a Rails 7.1 app, I have the form below <%= form_with model: @post do |form| %> <%= form.text_area :body %> <%= form.submit %> <% end %> And the related action. def ...
Sig's user avatar
  • 5,914
0 votes
2 answers
88 views

How to configure ActionController::Parameters to permit a moderately deep recursive structure

I want my JavaScript front-end to pass a recursive data structure to my Rails API. How do I configure the parameter to permit to handle a structure of unknown depth? Specifically, my data structure ...
Zack's user avatar
  • 6,556
0 votes
1 answer
92 views

Params missing ruby

Asistencia controller gets everything from user is CRUD where user, entry, password, username exists These are the parameters that should be updated and change the entry class AsistenciaController <...
William's user avatar
0 votes
1 answer
30 views

Missing parameters in ruby ​on rails

class AsistenciaController < ApplicationController def update if @asistencia.update(asistencia_params) redirect_to asistencia_path, notice: "Asistencia guardada correctamente" ...
Edrei Beltrán's user avatar
1 vote
2 answers
1k views

Rails strong params, require one key and permit another

I'm posting: {'a': 1, 'b': 2} where key a is always required and key b is optional. How do I require a and permit b using Rails strong params syntax? params.require(:a).permit(:b) doesn't work...
duhaime's user avatar
  • 27.5k
1 vote
2 answers
128 views

Rails strong parameters - multiple types (strings, array of strings and array of hashes)

I have the following params, that have different value type (1. string, 2. array of strings and 3. array of hashes) for the value key: Params project: { name: "Project 1", ...
Miroslav's user avatar
  • 176
1 vote
1 answer
440 views

Declare that the value in strong params must NOT be an array or of a one scalar type

Application accepts a GET request to index products and accepts page param (which should be an integer). e.g. http://localhost/products?page=2 Is there a way to ensure that it really is an integer? Or ...
romanstrazanec's user avatar
2 votes
0 answers
100 views

How to permit a array that can contain both a String and an Object with strong params?

Is easy to permit an array of scalar elements: ActionController::Parameters.new( schedule: ['2022-07-04'] ).permit(schedule: []).to_h => {"schedule"=>["2022-07-04"]} And ...
pragmatic_programmer's user avatar
0 votes
3 answers
205 views

Require structure with array of hash maps

I'm using Ruby on Rails 7 to build a REST API that accepts a payload via HTTP PATCH that looks like this: { "answers": [ {"question_id": 1, "content": "My ...
LondonAppDev's user avatar
  • 9,563
0 votes
0 answers
684 views

rails permit params setting nested nested array of json to empty

I ran into this very interesting problem which i am trying to resolve since last 3-4 hours, where i am not able to permit unknown nested array in json , its setting to empty array params=...
Shubham kumar's user avatar
0 votes
1 answer
279 views

dynamic list of params to be permited in rails

I am currently trying to permit params containing an array object. #My controller def students_params params.require(:student).permit(standards:[], subjects: []) end So here in my case, I will have ...
Amol Mohite's user avatar
0 votes
1 answer
1k views

Rails Strong Params how to Permit a nested Array

I have the following params: params={"data"=> {"type"=>"book", "id"=>14, "attributes"=> {"id"=>14, ...
lost9123193's user avatar
0 votes
1 answer
251 views

Rails strong params don't allow to pass data

I am trying to create an authentication component on with React on the FE and Rails BE. I'm not sure what's the issue here, when i send a request to the API to create the user. the password is not ...
user avatar
0 votes
1 answer
280 views

Rails: Accept 2D array of strings with strong parameters

We have a Rails controller that gets the following data: params = ActionController::Parameters.new({ "requests": [{ "params": { "facets": ["...
duhaime's user avatar
  • 27.5k
5 votes
2 answers
10k views

How to permit hash with rails strong params

I am working on a Model with an atter_accessor object named element. I want to pass the Array of form data to the element object. In Rails console I am getting Unpermitted parameter error. Parameters: ...
Santosh Aryal's user avatar
0 votes
1 answer
458 views

param is missing or the value is empty: user when enabling password access to a page in Rails app

I am getting this error: "param is missing or the value is empty: user" when I am trying to create password restricted access to user settings page in my app. All the logged in users can see ...
ascender'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
1 vote
0 answers
390 views

Rails permit params not working for multiple checkboxes and multi select

Creating new entry for Associate model have book_id and tag_id. My requirement is to have a list of checkboxes of books and multi-select for tags, which I have done like that <%= form....
Haseeb Ahmad's user avatar
  • 8,680
0 votes
2 answers
3k views

Ruby on Rails Wrong Number of arguments (given 0 expected 1)

hello iam trying to create a new record using Ruby on Rails models however iam getting a wrong num her of arguments error. error message: config/routes.rb Rails.application.routes.draw do mount ...
Ari Ticas's user avatar
0 votes
0 answers
569 views

Strong Parameters #require Convention in Rails API

I understand how the #require method works, but why/when should it be used. Is using require a best practice and why? At least for simple controllers and parameters, require seems pointless. For ...
Asdrubal's user avatar
  • 2,461
2 votes
1 answer
2k views

Rails When should I use strong parameters?

I am not sure if I understand the concept of strong parameters correctly. I should use strong parameters to params that I will use only to edit some data? Or I should use them for every params I want ...
N0ne's user avatar
  • 154
1 vote
1 answer
227 views

How can I store random nested variables with strong params methods in Rails?

I have the following class: class ArticlesController < ApplicationController def create article = Article.new(article_params) end private def ...
Samuel Da Costa's user avatar
0 votes
0 answers
208 views

Why does ActiveModel::Attributes.attribute cause permitted strong parameters to disappear in a controller?

I have a form model: class Foo include ActiveModel::Model include ActiveModel::Attributes attribute :bar, :string attr_reader :bazes end And a controller: class FoosController < ...
Benjamin Oakes's user avatar
0 votes
0 answers
131 views

rails 4, ActiveModel::ForbiddenAttributesError for nested `accepts_nested_attributes_for` model

I have a model Offer that accepts_nested_attributes_for :tenant and Tenant model that accepts_nested_attributes_for :tenant_qualification In my controller I have: @offer.assign_attributes offer_attrs ...
Don Giulio's user avatar
  • 3,254
0 votes
1 answer
326 views

Rails permit nested attribute

I am working on rails 6 with ruby-2.6.5 and i am working on the API. I am using nested attributes for my order as follows:- orders_controller.rb # frozen_string_literal: true module Api module V1 ...
awsm sid's user avatar
  • 595
0 votes
0 answers
70 views

Rails save and create function throwing in an extra method

I am able to create a new instance of my Team class successfully, but whenever I call save on the instance I get: undefined method `title' for #<Team:0x00007fddfc7fb570> This is in my "...
mycupisoverflowing's user avatar
0 votes
0 answers
648 views

Rails: Add attribute to nested attributes in controller

I have a model called Litter that accepts nested attributes for the model Puppy. When submitting an update to a litter I want to modify all the nested puppies so it adds a new attribute (breed_id). ...
amoks's user avatar
  • 103
0 votes
1 answer
141 views

Rails controller parameters are different from sending parameters

Rails parameters are different actual sending parameters Parameters sending from the postman: { "first_name": "Arun", "last_name": "Deepak", "email": &...
Kanna's user avatar
  • 1,010
0 votes
1 answer
390 views

How to update with strong parameter?

What I want to do My application has Order model and List model. List model is Order's child. Order has total column. List has price and quantity columns. I want to update the total of the Order by ...
naoyu_k's user avatar
  • 17
0 votes
1 answer
569 views

Dynamic / Regex params in ApplicationController

How to permit dynamic params in an AppicationController? so all these parameters should permitted: params = { "filter_color" => "blue,green", "filter_size" ...
Jan's user avatar
  • 15.9k
1 vote
1 answer
350 views

How to make dynamic strong params in Rails?

I am starting a project in which I am trying to have the least possible effort in the evolution, one of the points is the strong params that must be inserted in the Controller. With that, I created a ...
Hugo Silva's user avatar
1 vote
2 answers
878 views

How to permit params in Rails 4 where the variable param can be either string or hash?

How to permit params in Rails where the variable param can be either string or hash? for eg, how to permit param "abc"? "abc" => "xz" (case1) # or "abc" =&...
Divya Agarwal's user avatar
0 votes
1 answer
265 views

My nested attributes are not passing through the strong Params

I have a form for a delivery order that contains a form for a meal inside of it. A meal is made up of items, which are also objects. The form for a delivery looks as so... <%= form_for @delivery do ...
user avatar
1 vote
1 answer
485 views

I'm using active storage and its giving me a strong params error

So I'm trying to add audio mp3 to my back end using rails API, active storage, and a react frontend. It seems that the associations are messed up or not getting read? I've tried switching all the code ...
Jonathan Bleibdrey's user avatar
3 votes
0 answers
723 views

How to make Postman or Postman Collection Runner send a POST request with CSV file, rails strong parameters

In a Rails 6 api, I want to test a controller with strong parameters with Postman. In the controller: class ProcessorController < ApplicationController ... def create file = processor_params[:...
Ridhwaan Shakeel's user avatar
0 votes
1 answer
188 views

How to trust an association id parameter?

Here's an example of where we need to trust that the conversation_id wasn't altered by the user: # messages_controller.rb def create @message = Message.new( body: message_params[:body], # ...
stevec's user avatar
  • 51.5k
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
0 votes
0 answers
99 views

What is this extra parameter hitting my controller from?

I have a route in my Rails App labelled: get '/mookie.json', to: 'fizzbuzz#mookie' The controller method mookie accepts params, and I see them in my log. But the list of params is polluted with an ...
David Lazar's user avatar
  • 11.4k
0 votes
1 answer
4k views

Null value in column "created_at" violates not-null constraint when using upsert

Why is created_at null and how would I resolve this? ↳ app/controllers/projects_controller.rb:28:in `create' Tag Upsert (5.6ms) INSERT INTO "tags" ("category","name") ...
Daniel's user avatar
  • 23
0 votes
1 answer
563 views

Nested Form - I cannot get all of the attributes params to pass through to my strong params

Working on a project with a has_many_through join table with an additional attribute on the join table. My models are wines, foods, and the join table is pairings. I am not getting all of the ...
Maddog64's user avatar
0 votes
1 answer
207 views

Edit a strong param if it's present?

How can I conditionally edit a strong parameter? For example, I have the following which edits the strong parameter (country). It does something simple; changes it from long to short e.g. "United ...
dss's user avatar
  • 447
0 votes
0 answers
125 views

STI wth Strong params undefined local variable or method `attributes'

undefined local variable or method `attributes' for #CarsController:0x00007fa686991b30 def cars_params(type) params.require(type.to_sym).permit(attributes) end My model is CommonCar::RedTrunk,...
Lefty's user avatar
  • 675

1
2 3 4 5
20