Questions tagged [nested-attributes]
RubyOnRails allows you to access attributes of objects associated with the main model, using one, deep hash. Use this tag if you have problem with a model in which you defined `accepts_nested_attributes_for` or if you use nested calls of `fields_for` in a view.
nested-attributes
1,642
questions
0
votes
1
answer
48
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
57
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
35
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
34
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
39
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
66
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
81
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, ...
2
votes
1
answer
203
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
66
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
2k
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
25
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 ...
2
votes
1
answer
127
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
779
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
113
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
29
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" : "...