nested-forms

Update multiple checkboxes on association model through nested attributes with Cocoon gem in Rails

拟墨画扇 提交于 2021-02-10 06:43:47
问题 I found this answer here which should be able to solve my problem but turns out that answer is for a one to many association. Btw, i'm using Rails 5.2 In my many to many, I have a Task model which has_many test_methods through tasks_test_methods where tasks_test_methods is a join table. class Task < ApplicationRecord has_many :tasks_test_methods, inverse_of: :task, :dependent => :destroy has_many :test_methods, :through => :tasks_test_methods accepts_nested_attributes_for :tasks_test_methods,

Nested checkboxes in Rails

与世无争的帅哥 提交于 2021-02-08 08:59:43
问题 I'm trying to create an event app where each event has multiple tables and each table has multiple people sitting at a table the event has multiple tickets which map the people to the tables that they are sitting at -> in order to achieve this I have created a checkbox nested in the fields_for :tables (which is in turn in the event form) I presume something is wrong with either the strong parameters or the form itself but I have not been able to find any information that provides a solution

Nested checkboxes in Rails

試著忘記壹切 提交于 2021-02-08 08:58:01
问题 I'm trying to create an event app where each event has multiple tables and each table has multiple people sitting at a table the event has multiple tickets which map the people to the tables that they are sitting at -> in order to achieve this I have created a checkbox nested in the fields_for :tables (which is in turn in the event form) I presume something is wrong with either the strong parameters or the form itself but I have not been able to find any information that provides a solution

Rails 5 - save rolls back because nested models parent model is not being saved before child model

天大地大妈咪最大 提交于 2021-02-07 09:33:39
问题 Ok folks, Rails 5 has really had its nuances differing from Rails 4. What I have going on is that every time I click the submit button on the form it reloads with the error Profile user must exist and Profile user can't be blank . The form loads fine including the nested models form, but for what ever reason it is failing to save the parent model before attempting to save the child model with the following output to the console: Puma starting in single mode... * Version 3.7.0 (ruby 2.2.6-p396

ngTemplateOutlet - Angular 5 nested template driven form

柔情痞子 提交于 2021-01-04 10:36:14
问题 I have a ng-template which is being passed on from one of my component and i have a placeholder to accept the passed on ng-template onto my component as shown below in ngTemplateOutlet. <div> <form novalidate #myForm="ngForm"> <ng-container> <ng-template [ngTemplateOutlet]="myTemplate"> </ng-template> </ng-container> </form> </div> <!-- this template i am passing it from one of my other components --> <ng-template #myTemplate> <input type="text" name="myInput" placeholder="Input" [(ngModel)]=

Rails before_update callback with nested attributes

风格不统一 提交于 2020-02-07 11:23:29
问题 I have two models (lets call then A and B ). A has_many b s and B belongs_to A . class A < ApplicationRecord has_many :bs, dependent: :destroy, inverse_of: :a accepts_nested_attributes_for :bs, reject_if: :all_blank, allow_destroy: true validates_associated :bs end class B < ApplicationRecord belongs_to :a, inverse_of: :bs before_update :do_something, unless: Proc.new { |b| b.a.some_enum_value? if a } def do_something self.some_field = nil end end Other than that, B has a before_update

Cocoon Item field not posting values to database

依然范特西╮ 提交于 2020-01-15 10:18:11
问题 I have a genearted lineItem field using Cocoon gem, am having issues trying to save the line items field values,and when I inspect the elements the add_item button wasn't triggering a unique ID for each new field generated. class InvoicesController < ApplicationController before_action :set_invoice,:set_line_item, only: [:show, :edit, :update, :destroy] def index @invoices = Invoice.all end def show end def new @invoice = Invoice.new @invoice.line_items.build end def edit end def create

No errors and no output for rails cocoon gem

痞子三分冷 提交于 2020-01-11 10:31:08
问题 I am working on a dynamically nested form using the cocoon gem. I have two models class CrossTable < ActiveRecord::Base attr_accessible :title, :table_name, :database, :folder_label_id, :foreign_fields_attributes belongs_to :folder_label has_many :foreign_fields accepts_nested_attributes_for :foreign_fields validates :title, :table_name, :database, :folder_label_id, presence: true end class ForeignField < ActiveRecord::Base attr_accessible :cross_table_id, :column_name, :description belongs

Rails - I can't display locations on my users form using nested forms

六眼飞鱼酱① 提交于 2020-01-07 07:43:06
问题 I can't display the locations that belogns to the user using nested forms. I want to create the user and save the address, city, state, etc in location model and the name, username, email in the user model. I have no errors on the console. But the fields (select or dropdowns, text_fields, etc) are not showing up. The database has records. This is my user.rb model: class User < ActiveRecord::Base has_many :locations accepts_nested_attributes_for :locations end This is my location.rb model:

Rails nested forms only passing the id on form submit

半城伤御伤魂 提交于 2020-01-07 01:49:13
问题 No idea whats going wrong here. From memory it used to work fine but I just recently used the form and realised it has stopped working somewhere in the process of building the app. Mini test still passes it which could mean it is something trivial or on the form directly. I'm trying to get the nested attribute value to pass on the from submit category_item model has_many :category_item_values, dependent: :destroy accepts_nested_attributes_for :category_item_values extend FriendlyId friendly