nested-form-for

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

Rails nested_form inside nested_form

本秂侑毒 提交于 2019-12-25 07:20:09
问题 I have the following models and relations: Rate fields t.string :type t.string :name class Rate < ActiveRecord::Base has_many :category_rate_requests end CategoryRateRequests fields t.date :date_from t.date :date_to class CategoryRateRequests < ActiveRecord::Base belongs_to :rate has_many :category_rates end CategoryRate t.integer :room_category_id t.integer :new_rate_id t.integer :category_rate_request_id t.integer :amount class CategoryRate < ActiveRecord::Base belongs_to :rate belongs_to

NoMethodError within nested model form

故事扮演 提交于 2019-12-23 05:12:19
问题 The project is a simple workout creator where you can add exercises to a workout plan. I've been following the Railscast covering nested model forms to allow dynamically adding and deleting exercises, but have run into an error and need a second opinion as a new developer. The error I am continually receiving is: NoMethodError in Plans#show This is the extracted code, with starred line the highlighted error: <fieldset> **<%= link_to_add_fields "Add Exercise", f, :exercise %>** <%= f.text

Invalid association. Make sure that accepts_nested_attributes_for is used for :questions association

牧云@^-^@ 提交于 2019-12-23 03:38:10
问题 i am building nested form in rails 4.I keep getting this error my _form.html.erb as <%= nested_form_for (@project) do |f| %> <% if @project.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@project.errors.count, "error") %> prohibited this project from being saved:</h2> <ul> <% @project.errors.full_messages.each do |message| %> <li><%= message %></li> <% end %> </ul> </div> <% end %> <div class="field"> <%= f.label :name %><br> <%= f.text_field :name %> </div> <%= f.fields_for

Getting undefined method `values_at' for nil:NilClass using nested_form_for

孤街浪徒 提交于 2019-12-22 10:53:51
问题 I'm using nested_form gem from ryanb and it doesn't seem to be working properly. The remove link doesn't work (I installed the //= require jquery_nested_form properly and it looks like it's loading but i keep getting this error: undefined method `values_at' for nil:NilClass when i go to add: = f.link_to_add "Add a line item", :invoice_line_items also, without that line it works but the remove link doesn't do anything: line_item.link_to_remove "Remove this line item" here's my code: .row-fluid

rails - dynamic select menus within nested_form_for

六眼飞鱼酱① 提交于 2019-12-12 09:08:53
问题 I'm using the nested_form_for in the usual way but I want to add dynamic select menus to the nested children. I have the following coffee script (adapted from the 'dynamic-select-menus' railscast) jQuery -> $( ".controls-row" ).each -> $(this).bind "change", -> type = $('#expense_type :selected').text() if (type == "miles") $('#amount_currency').hide() $('#km_traveled').show() else $('#amount_currency').show() $('#km_traveled').hide() the problem with this code is that it will only work with

Invalid association. Make sure that accepts_nested_attributes_for is used for :questions association

让人想犯罪 __ 提交于 2019-12-06 21:47:32
i am building nested form in rails 4.I keep getting this error my _form.html.erb as <%= nested_form_for (@project) do |f| %> <% if @project.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@project.errors.count, "error") %> prohibited this project from being saved:</h2> <ul> <% @project.errors.full_messages.each do |message| %> <li><%= message %></li> <% end %> </ul> </div> <% end %> <div class="field"> <%= f.label :name %><br> <%= f.text_field :name %> </div> <%= f.fields_for :questions do |builder| %> <%= render "question_fields", :f => builder %> <% end %> <div class="actions">

Getting undefined method `values_at' for nil:NilClass using nested_form_for

江枫思渺然 提交于 2019-12-06 01:58:39
I'm using nested_form gem from ryanb and it doesn't seem to be working properly. The remove link doesn't work (I installed the //= require jquery_nested_form properly and it looks like it's loading but i keep getting this error: undefined method `values_at' for nil:NilClass when i go to add: = f.link_to_add "Add a line item", :invoice_line_items also, without that line it works but the remove link doesn't do anything: line_item.link_to_remove "Remove this line item" here's my code: .row-fluid .span10.offset1 = nested_form_for(@invoice) do |f| - if @invoice.errors.any? #error_explanation %h2 =

rails - dynamic select menus within nested_form_for

。_饼干妹妹 提交于 2019-12-04 17:07:30
I'm using the nested_form_for in the usual way but I want to add dynamic select menus to the nested children. I have the following coffee script (adapted from the 'dynamic-select-menus' railscast ) jQuery -> $( ".controls-row" ).each -> $(this).bind "change", -> type = $('#expense_type :selected').text() if (type == "miles") $('#amount_currency').hide() $('#km_traveled').show() else $('#amount_currency').show() $('#km_traveled').hide() the problem with this code is that it will only work with the first nested element. I tried adding unique id's to each of the elements but that only works for