74 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
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
1
answer
68
views
Rails accepts_nested_attributes_for unable to associate (or find) record passed in
Our Attachment model (in this case used for logos associated to teams) gets saved to the database before we associate it to the team. We do that because we do client side S3 uploading, so we need to ...
1
vote
2
answers
83
views
Can I set values for accepts_nested_attributes_for children easily?
As a trivial example, let's say I have:
class Garage
has_many :things
accepts_nested_attributes_for :things
end
class Thing
# has a name attribute
belongs_to :garage
belongs_to :user
end
...
0
votes
3
answers
563
views
Rails Has Many Validate Unique Attribute With Accepts Nested Attributes For
I have Invoices with many Invoice Line Items. Invoice line items point to a specific item. When creating or updating an Invoice, I'd like to validate that there is not more than 1 invoice line item ...
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, ...
0
votes
1
answer
114
views
Rails simple form submits but nested fields from data doesn't persist
I'm working on a rails CMS project and I am trying to create from the admin dashboard, a quotes section where users can add a section_quote with title, image and five quotes with their authors(5 ...
0
votes
1
answer
367
views
Rails Nested Fields With Cocoon - link_to_add_association is Deleting Records
I'm using nested fields and accept nested attributes with a 3 level nested relationship. The 3rd level (I don't think it matters that it's third level) relationship gets deleted when editing the ...
1
vote
2
answers
116
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 ...
0
votes
0
answers
160
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&...
1
vote
1
answer
155
views
Recursive accepts_nested_attributes_for in Rails, is it possible?
I want to create a tree structure between two models, Bar and Foo.
Bar has many Foos
Bar
/ | \
Foo Foo Foo
¦
Bar
/ | \
Foo Foo Foo
Bar can optionally belong to ...
0
votes
1
answer
234
views
Rails + Javascript: Create one parent model and multiple child model in same time
I have a parent model (paper) and a nested child model (tape) and want to create multiple child with a parent in same time without using any gems.
The input fields of tape should be dynamically added ...
3
votes
1
answer
1k
views
Unable to UPDATE nested attributes even when providing record ID
I am trying to update nested records, but for some reason it does not work and my update action is ignored. If I run the following code in console, it returns true, but nothing is actually updated for ...
2
votes
0
answers
120
views
Ruby on Rail Nested Attributes do not save to database
I am trying to create a form that updates 2 tables - commission_type and commission_tier.
I created the models, controller and form but when I submit it, my commission_tier table does not update. Only ...
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
262
views
How to avoid saving nil/blank in accepts_nested_attributes_for when displaying set number of fields for has_many association?
My question is an edgecase of how to avoid saving empty records on a nested rails form. I have a simple has_many, where a user can have a maximum of 5 job titles.
# user.rb
has_many :job_titles
...