1,643 questions
1
vote
1
answer
82
views
Idiomatic Rails way to select records with checkboxes in a big form to choose whether to save or not
I’m building a Rails app related to golf. Users can search for golf courses via an API, and the results are rendered as individual forms per course.
Right now, each course must be saved individually, ...
-3
votes
1
answer
124
views
Rails Devise Strong Parameters not building Nested Association
I did generated devise controllers and views and defined both User and Account models like the following:
User
class User < ApplicationRecord
# Include default devise modules. Others available ...
0
votes
2
answers
84
views
Get a sum value from nested attributes, in Python
I need to code a SEARCH class, so that accessing its attributes by their nested representation(s).
Attributes and their relationship: the goal of the 'SEARCH' class is to obtain a serie of consecutive ...
0
votes
0
answers
49
views
"Rails: NoMethodError for Nested Attributes in Form Submission
Description:
I'm working on a Rails application where I have a Picture model that has a nested Pictureclass model. The index (the gallery of pictures) and the show (a detail of the picture) are ...
0
votes
1
answer
73
views
Defining translations for nested forms in namespaced resources
I have the below setup
class BudgetLine < ApplicationRecord
has_many :budget_line_items
accepts_nested_attributes_for :budget_line_items
end
class BudgetLine::Accommodation < BudgetLine
end
...
0
votes
2
answers
165
views
How can I select elements based on an attribute of a child of a parent element's previous sibling?
Is there way I can hide the 2nd and 3rd anchor elements inside the li elements using CSS? Also, it needs to be hidden based on the attribute selector "isInternalUser=true" which is there in ...
0
votes
0
answers
44
views
Rails unable to update multiple nested attributes at once?
I have a deeply nested attributes controller, like this:
def update
@product = Product.find(params[:id])
authorize @product
if @product.update(product_params)
render status: :...
1
vote
1
answer
44
views
Unpermitted Parameter error in Rails for nested nested form submission
I'm trying to create a quiz builder where a user builds a quiz that is added to the Quiz model, a question that is in the QuizQuestions model and answer choices in and AnswerChoices model.
The Quiz is ...
1
vote
0
answers
55
views
Keep nested attribute's values to show validation errors on form submit
I have a model Parent
class Parent < ApplicationRecord
has_many :jobs
accepts_nested_attributes_for :jobs, allow_destroy: true
end
and model Job
class Job < ApplicationRecord
belongs_to :...
0
votes
1
answer
116
views
Unpermitted Params using Polymorphic Association in Rails 7
Based on image above, I do a simple example.
Model: Person
class Person < ApplicationRecord
belongs_to :personable, polymorphic: true
end
Model: Customer
class Customer < ApplicationRecord
...
1
vote
2
answers
114
views
Rails form for not creating unique ids
This is driving me crazy.
I have 2 models, StockShipment has_many Recipients.
It also has:
accepts_nested_attributes_for :recipients, reject_if: :all_blank, allow_destroy: true
I have this partial, ...
3
votes
1
answer
349
views
How to automatically assign parent ID as foreign key when using nested attributes?
An action creates records based on multiple layers of nested attributes, upon the submission of a form. However, the ID of the root record, which I call .save on, is not propagating downwards to the ...
0
votes
1
answer
74
views
Displaying information from unrelated nested models
I'm building a Rails application with two models, both with a further two nested models:
Contacts -> Trackers -> Emails
and
Goals -> Stages -> Templates
I want to display information from ...
0
votes
1
answer
3k
views
Ransack, unable to search two attributes
I'm a beginner trying to make a searchbar, i'm with a simple attribute research, works fine, but when i try to add another attribute in the search_field, i have an error : "Ransack needs Product ...
0
votes
0
answers
33
views
Rails flexible checklists
I need advice if my approach is right
I would like to create a digital checklist for several test types with the possibility that users can add further questions to the checklist at any time.
I have ...
3
votes
1
answer
232
views
Rails: creating nested attributes with manually set IDs
I have a rails API that injects primary key IDs from the client, as opposed to autogenerating through Rails. Specifically:
class ParentModel < ApplicationRecord
accepts_nested_attributes_for: ...
2
votes
1
answer
1k
views
how to translate Nested Attributes on laravel validation?
I have a problem translating nested attributes on laravel validation, the code im using is like:
$this->validate($request,[
'title.*' => 'required'
]);
and * can be: en, es, fa ... and other ...
0
votes
1
answer
149
views
Nested fields in form is not rendering
Im new to ruby on rails so i need some tips please.
Im trying to render some checkboxes on the edit view for a user.
I have tried to follow the documentation for the nested_attributes but the ...
0
votes
1
answer
30
views
Display value within top level document of nested document field value in mongoDB
This is the document from where i wanted to pull data from
{
"_id" : ObjectId("635cbfee36945e4a79b0af70"),
"EID" : 200,
"EName" : "...
1
vote
1
answer
403
views
nested attributes with has many through
I am getting unpermitted params when I am passing values from UI. The association is many to many between models.
class User < ApplicationRecord
has_many :user_posts
has_many :posts, ...
1
vote
0
answers
109
views
Working with Form Object and nested attributes: Couldn't find JoinTableRecord with ID=1 for Parent with ID=
I'm working on a form object where I build and save an instance of Service, but I'm having a hard time building and saving nested records.
A Service has_one features_set and ...
-2
votes
3
answers
302
views
Filter according field on array object
I have an object is data like this :
Original data
const data = {
"title": "sunny",
"members": [
{
"fullname": "rozo",
"customers": [
{
&...
3
votes
3
answers
2k
views
Alternatives to attrdict library for nested AttrDict
My program contains a lot of configuration parameters so I was looking for a way to have them all in one place, accessible from every file in the project.
I thought about a config module which would ...
0
votes
0
answers
63
views
How to setup this complex nested attributes hash
I have product, feature, product_feature, and quota.
# product.rb
has_many :product_features, dependent: :destroy
has_many :quotas, through: :product_features
has_many :features, through: :...
0
votes
1
answer
66
views
Rails: Cannot set the value of text_field with jquery
I am trying to update the value of an item codenumber field every time the user selects an item from a list using jquery. My view is like this.
<tr class="nested-fields">
<td ...
0
votes
1
answer
406
views
Nested parameter does not include <name>_attributes in Rails 7 when submitting nested attributes
I'm facing this issue and after digging, I can't seem to find a solution for this.
I'm trying to create a user and his meet_infos on a nested form, but in the params, I always end up with "...
1
vote
1
answer
204
views
Building new Model A form from Model B attributes
I'm trying to copy the values from Model A nested attributes to Model B nested attributes. The nested fields are the same in their respective tables. Just the parents are different.
I pass the model A ...
0
votes
0
answers
34
views
Create multiple associated records in a single form [duplicate]
I'd like a User to be able to create an Event and associated Invitations. An Invitation is a join table between User and Event (with an enum for its state, default to pending).
Eligible users are ...
1
vote
2
answers
113
views
Is there a suggested way to create nested many-to-many entities in RoR that avoids *_attributes in the JSON field for the nested resource?
I've managed to get nested many-to-many entities created through the use of accepts_nested_attributes_for for the JSON and the project below.
My question is - is there a suggested way to achieve the ...
1
vote
1
answer
1k
views
How to get data based on condition from nested array golang grpc service
I'm trying to get specific data based on next array condition in Go. I think, I will just give an example to make it clear.
Let's say I have an array like this
detail: {
contacts: [
{
...
0
votes
0
answers
157
views
Rails nested attributes method delete not working correctly
I have two models: Article and Paragraph. One Article can include much Paragraphs.
Article model:
class Article < ApplicationRecord
#enum category: {wiki: "Wiki", rules: "Rules&...
0
votes
0
answers
286
views
Create child association from controller
I have 2 associated models and am trying to create the child from the parent's controller:
class Purchase < ActiveRecord::Base
has_many :comments, as: :commentable, dependent: :destroy
...
0
votes
0
answers
22
views
Saving Paginated child only when Parent get saved in Rails
I have application with form containing Parents with its Child rendered through Nested Attributes in view for edit.
Take example of Hr trying to edit an employee details along with his skill ratings. ...
1
vote
0
answers
105
views
How can I accept array params inside a nested form?
I'm making an app where users can create and edit Surveys with a number of Questions. Instead of an Answer class, I am serializing the possible answers for each Question as an array in a column named ...
0
votes
1
answer
494
views
Update nested attributes objects independently from parent model
I have a parent model 'page' and nested attributes model 'page_modules' which at same time are modeled by 'Single Table Inheritance' pattern.
My problem is when I try to save different generated '...
0
votes
1
answer
976
views
Rails form with nested attributes in has_many through relationship
I'm attempting to build a form with multiple nested objects in a has_many :through relationship. However, the nested objects do not appear to be getting assigned the foreign_key of the parent object ...
0
votes
1
answer
427
views
Filtering nested attributes in rails API json output
Im building an API in which i have a model called Studio. Studio has many movies and many series, and movies and series have many characters of their own. Also, a character can be in many movies and/...
0
votes
1
answer
182
views
Ruby on Rails - Problem with nested_attributes validation when allow_destroy: true
I have some model with accepts_nested_attributes_for
class SomeModel < ApplicationRecord
has_many :some_resources
accepts_nested_attributes_for :some_resources, allow_destroy: true
......
0
votes
1
answer
531
views
Rails 6: Nested Form not saving
I have been trying to get a simple test example of a nested form in Rails 6 running but so far I have not been able to create an example that works. As far as I know I created a correct association in ...
1
vote
0
answers
55
views
Rails 6 Nested Attributes, Uniquness Validation Failing on destroyed records
I am facing issue in validating nested attributes uniquness. I have 2 models
#model : CompanyStore
class CompanyStore < ApplicationRecord
has_many :company_stores_brands, dependent: :destroy
...
0
votes
0
answers
116
views
Change OBJECT ATTRIBUTE that it is ATTRIBUTE of an other OBJECT in PYTHON
I am trying to implement a structural analysis class and I getting the following error.
The idea is to assign a CrossSection object to a Beam object and assign the value of Beam.eleTag attribute (...
0
votes
0
answers
52
views
What the buildpack should i add for the nested attributes to make it work in heroku?
What the buildpack should i add for the link_to_add_association to make it work in heroku?
for some reason the gem cocoon works locally but not working in heroku
Someone mention to add buildpack to my ...
0
votes
0
answers
130
views
gem cocoon work locally but not in production
I did alot of research to make this work. but nothing solved mine
link_to_add_association not working in heroku
gem "cocoon"
<%= form_for(resource, as: resource_name, url: ...
0
votes
1
answer
2k
views
link_to_add_association and link_to_remove_association Nested form Cocoon gem
his is the first time I am using cocoon gem so I am not sure how to use it properly,I am not getting error but the link_to_add_association is not working." link_to_remove_association" gives &...
0
votes
0
answers
44
views
Saving in two tables from one form / first implementation - no insertion / second - no implicit conversion of Symbol into Integer
I want to insert into two database tables by clicking on a button. And there are several problems:
First Problem:
Models:
class Dish < ApplicationRecord
has_many :courses
has_many :days, ...
-1
votes
1
answer
399
views
Rails 4 Accept nested attributes with has_one association
I have a question about Rails Nested Attributes.
I'm using Rails 4 and have this model:
model Location
has_one parking_photo
has_many cod_photos
accepts_nested_attributes_for :parking_photo
...
0
votes
2
answers
62
views
Rails 5 how to edit join model attributes from the parent model's view?
I have a system where admins can create Exams and price them according to the Branch they are selling them in. So for example, Exam One can cost $5 in Branch One, but $10 in Branch Two.
I made a join ...
-1
votes
1
answer
119
views
"ActiveModel::ForbiddenAttributesError " on Rails App ( 5) with nested attributes
I have a simple_form_for that creates an invoice. Through this form, I want the user to be able to create a client that will be associated with that before-mentionned invoice. The current process ...
0
votes
1
answer
107
views
Model with nested attributes doesn't show fields_for in field that is not an attribute in the model
I have an Exam and an ExamBattery that is just a collection of Exams. They have a has_and_belong_to_many declaration for each other, and ExamBattery accepts nested attributes for Exam, like so:
class ...
1
vote
3
answers
579
views
Simple form with has_many through and join table
I have models: Product, Parts and ProductParts
product.rb
class Product < ApplicationRecord
has_many :product_parts
has_many :parts, through: :product_parts
accepts_nested_attributes_for :...