Values for nested fields not saving without error | Rails 5.2
I'm working on a Rails 5.2 application requiring the storing of a Quote
, and one QuoteLineItem
to go wwith it (Quote
has_one :quote_line_item
, QuoteLineItem
belongs_to :quote
). I've set it all up according to documentation, however when submitting the quotes#edit
for (which contains fields_for @quote.quote_line_item...
), the values for the Quote
record are updated in the database, however values for the QuoteLineItem
are not. No error is thrown on submission, and no "Unpermitted params..." message in server logs.
Quote Model
class Quote < ApplicationRecord
has_one :quote_line_item, inverse_of: :quote, dependent: :destroy
accepts_nested_attributes_for :quote_line_item, update_only: true
end
QuoteLineItem Model
class QuoteLineItem < ApplicationRecord
belongs_to :quote, inverse_of: :quote_line_item, touch: true
end
Quotes Controller
class QuotesController < ApplicationController
def update
@quote = Quote.find(params[:id])
if @quote.update(quote_params)
flash[:success] = "Quote was successfully updated."
redirect_to @quote
else
flash[:error] = "Quote was not updated. Please try again."
render :edit
end
end
private
def quote_params
params.require(:quote).permit(:issued_at, quote_line_item_attributes: [ :kind, :description, :price ])
end
end
Quotes Edit View
<%= form_for @quote do |quote_form| %>
<% if @quote.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@quote.errors.count, "error") %> prohibited this quote from being saved:</h2>
<ul>
<% @quote.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<%= quote_form.label :issued_at %>
<%= quote_form.datetime_field :issued_at %>
<%= fields_for :quote_line_item, @quote.quote_line_item do |quote_line_item_fields| %>
<%= quote_line_item_fields.label :description %><br>
<%= quote_line_item_fields.text_field :description %>
<%= quote_line_item_fields.label :price %>
<%= quote_line_item_fields.number_field :price, step: :any %>
<% end %>
<% end %>
Server Logs
Started PATCH "/quotes/62" for 127.0.0.1 at 2018-11-12 13:01:46 +0800
Processing by QuotesController#update as HTML
Parameters: "utf8"=>"✓", "authenticity_token"=>"bVa+vhRayuPDhe5xkLcK2rm10zQ9oHvtDSZsKDhMBsdX/JDjf6uXsnIJ7gM/yP7Lt9E+aBGIR9WCoLU2uNhgVQ==", "quote"=>"issued_at"=>"12/11/2018 11:05 AM", "quote_line_item"=>"description"=>"QuoteLineItem description goes here...", "price"=>"800.00", "commit"=>"Save", "id"=>"62"
Quote Load (3.8ms) SELECT `quotes`.* FROM `quotes` WHERE `quotes`.`id` = 62 LIMIT 1
↳ app/controllers/quotes_controller.rb:127
(0.7ms) BEGIN
↳ app/controllers/quotes_controller.rb:53
(3.6ms) COMMIT
↳ app/controllers/quotes_controller.rb:53
Redirected to http://localhost:3000/quotes/62
Completed 302 Found in 44ms (ActiveRecord: 9.3ms)
Is there a reason this shouldn't be working?
Thanks.
ruby-on-rails ruby rails-activerecord nested-attributes
|
show 11 more comments
I'm working on a Rails 5.2 application requiring the storing of a Quote
, and one QuoteLineItem
to go wwith it (Quote
has_one :quote_line_item
, QuoteLineItem
belongs_to :quote
). I've set it all up according to documentation, however when submitting the quotes#edit
for (which contains fields_for @quote.quote_line_item...
), the values for the Quote
record are updated in the database, however values for the QuoteLineItem
are not. No error is thrown on submission, and no "Unpermitted params..." message in server logs.
Quote Model
class Quote < ApplicationRecord
has_one :quote_line_item, inverse_of: :quote, dependent: :destroy
accepts_nested_attributes_for :quote_line_item, update_only: true
end
QuoteLineItem Model
class QuoteLineItem < ApplicationRecord
belongs_to :quote, inverse_of: :quote_line_item, touch: true
end
Quotes Controller
class QuotesController < ApplicationController
def update
@quote = Quote.find(params[:id])
if @quote.update(quote_params)
flash[:success] = "Quote was successfully updated."
redirect_to @quote
else
flash[:error] = "Quote was not updated. Please try again."
render :edit
end
end
private
def quote_params
params.require(:quote).permit(:issued_at, quote_line_item_attributes: [ :kind, :description, :price ])
end
end
Quotes Edit View
<%= form_for @quote do |quote_form| %>
<% if @quote.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@quote.errors.count, "error") %> prohibited this quote from being saved:</h2>
<ul>
<% @quote.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<%= quote_form.label :issued_at %>
<%= quote_form.datetime_field :issued_at %>
<%= fields_for :quote_line_item, @quote.quote_line_item do |quote_line_item_fields| %>
<%= quote_line_item_fields.label :description %><br>
<%= quote_line_item_fields.text_field :description %>
<%= quote_line_item_fields.label :price %>
<%= quote_line_item_fields.number_field :price, step: :any %>
<% end %>
<% end %>
Server Logs
Started PATCH "/quotes/62" for 127.0.0.1 at 2018-11-12 13:01:46 +0800
Processing by QuotesController#update as HTML
Parameters: "utf8"=>"✓", "authenticity_token"=>"bVa+vhRayuPDhe5xkLcK2rm10zQ9oHvtDSZsKDhMBsdX/JDjf6uXsnIJ7gM/yP7Lt9E+aBGIR9WCoLU2uNhgVQ==", "quote"=>"issued_at"=>"12/11/2018 11:05 AM", "quote_line_item"=>"description"=>"QuoteLineItem description goes here...", "price"=>"800.00", "commit"=>"Save", "id"=>"62"
Quote Load (3.8ms) SELECT `quotes`.* FROM `quotes` WHERE `quotes`.`id` = 62 LIMIT 1
↳ app/controllers/quotes_controller.rb:127
(0.7ms) BEGIN
↳ app/controllers/quotes_controller.rb:53
(3.6ms) COMMIT
↳ app/controllers/quotes_controller.rb:53
Redirected to http://localhost:3000/quotes/62
Completed 302 Found in 44ms (ActiveRecord: 9.3ms)
Is there a reason this shouldn't be working?
Thanks.
ruby-on-rails ruby rails-activerecord nested-attributes
Can you please add log when you hit the update action?
– Vishal
Nov 12 '18 at 4:37
@Vishal I've added server logs for thequotes#update
action.
– slehmann36
Nov 12 '18 at 4:43
check your parameters forquote_line_item
it should bequote_line_items_attributes
. can you please try with this ` accepts_nested_attributes_for :quote_line_items, update_only: true ` and check how parameters are passing with this.
– Vishal
Nov 12 '18 at 4:45
@Vishal thanks for the suggestion. With your suggested updates, I receive the errorNo association found for name 'quote_line_items'. Has it been defined yet?
. The documentation shows that the model should be referenced in a singular form if the association is ahas_one
. Thanks
– slehmann36
Nov 12 '18 at 4:52
Okay, it should be onlyaccepts_nested_attributes_for :quote_line_item, update_only: true
, but you need to pass the parameters correctly. in form, try this<%= fields_for :quote_line_item, @quote.quote_line_item do |quote_line_item_fields| %>
– Vishal
Nov 12 '18 at 4:55
|
show 11 more comments
I'm working on a Rails 5.2 application requiring the storing of a Quote
, and one QuoteLineItem
to go wwith it (Quote
has_one :quote_line_item
, QuoteLineItem
belongs_to :quote
). I've set it all up according to documentation, however when submitting the quotes#edit
for (which contains fields_for @quote.quote_line_item...
), the values for the Quote
record are updated in the database, however values for the QuoteLineItem
are not. No error is thrown on submission, and no "Unpermitted params..." message in server logs.
Quote Model
class Quote < ApplicationRecord
has_one :quote_line_item, inverse_of: :quote, dependent: :destroy
accepts_nested_attributes_for :quote_line_item, update_only: true
end
QuoteLineItem Model
class QuoteLineItem < ApplicationRecord
belongs_to :quote, inverse_of: :quote_line_item, touch: true
end
Quotes Controller
class QuotesController < ApplicationController
def update
@quote = Quote.find(params[:id])
if @quote.update(quote_params)
flash[:success] = "Quote was successfully updated."
redirect_to @quote
else
flash[:error] = "Quote was not updated. Please try again."
render :edit
end
end
private
def quote_params
params.require(:quote).permit(:issued_at, quote_line_item_attributes: [ :kind, :description, :price ])
end
end
Quotes Edit View
<%= form_for @quote do |quote_form| %>
<% if @quote.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@quote.errors.count, "error") %> prohibited this quote from being saved:</h2>
<ul>
<% @quote.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<%= quote_form.label :issued_at %>
<%= quote_form.datetime_field :issued_at %>
<%= fields_for :quote_line_item, @quote.quote_line_item do |quote_line_item_fields| %>
<%= quote_line_item_fields.label :description %><br>
<%= quote_line_item_fields.text_field :description %>
<%= quote_line_item_fields.label :price %>
<%= quote_line_item_fields.number_field :price, step: :any %>
<% end %>
<% end %>
Server Logs
Started PATCH "/quotes/62" for 127.0.0.1 at 2018-11-12 13:01:46 +0800
Processing by QuotesController#update as HTML
Parameters: "utf8"=>"✓", "authenticity_token"=>"bVa+vhRayuPDhe5xkLcK2rm10zQ9oHvtDSZsKDhMBsdX/JDjf6uXsnIJ7gM/yP7Lt9E+aBGIR9WCoLU2uNhgVQ==", "quote"=>"issued_at"=>"12/11/2018 11:05 AM", "quote_line_item"=>"description"=>"QuoteLineItem description goes here...", "price"=>"800.00", "commit"=>"Save", "id"=>"62"
Quote Load (3.8ms) SELECT `quotes`.* FROM `quotes` WHERE `quotes`.`id` = 62 LIMIT 1
↳ app/controllers/quotes_controller.rb:127
(0.7ms) BEGIN
↳ app/controllers/quotes_controller.rb:53
(3.6ms) COMMIT
↳ app/controllers/quotes_controller.rb:53
Redirected to http://localhost:3000/quotes/62
Completed 302 Found in 44ms (ActiveRecord: 9.3ms)
Is there a reason this shouldn't be working?
Thanks.
ruby-on-rails ruby rails-activerecord nested-attributes
I'm working on a Rails 5.2 application requiring the storing of a Quote
, and one QuoteLineItem
to go wwith it (Quote
has_one :quote_line_item
, QuoteLineItem
belongs_to :quote
). I've set it all up according to documentation, however when submitting the quotes#edit
for (which contains fields_for @quote.quote_line_item...
), the values for the Quote
record are updated in the database, however values for the QuoteLineItem
are not. No error is thrown on submission, and no "Unpermitted params..." message in server logs.
Quote Model
class Quote < ApplicationRecord
has_one :quote_line_item, inverse_of: :quote, dependent: :destroy
accepts_nested_attributes_for :quote_line_item, update_only: true
end
QuoteLineItem Model
class QuoteLineItem < ApplicationRecord
belongs_to :quote, inverse_of: :quote_line_item, touch: true
end
Quotes Controller
class QuotesController < ApplicationController
def update
@quote = Quote.find(params[:id])
if @quote.update(quote_params)
flash[:success] = "Quote was successfully updated."
redirect_to @quote
else
flash[:error] = "Quote was not updated. Please try again."
render :edit
end
end
private
def quote_params
params.require(:quote).permit(:issued_at, quote_line_item_attributes: [ :kind, :description, :price ])
end
end
Quotes Edit View
<%= form_for @quote do |quote_form| %>
<% if @quote.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@quote.errors.count, "error") %> prohibited this quote from being saved:</h2>
<ul>
<% @quote.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<%= quote_form.label :issued_at %>
<%= quote_form.datetime_field :issued_at %>
<%= fields_for :quote_line_item, @quote.quote_line_item do |quote_line_item_fields| %>
<%= quote_line_item_fields.label :description %><br>
<%= quote_line_item_fields.text_field :description %>
<%= quote_line_item_fields.label :price %>
<%= quote_line_item_fields.number_field :price, step: :any %>
<% end %>
<% end %>
Server Logs
Started PATCH "/quotes/62" for 127.0.0.1 at 2018-11-12 13:01:46 +0800
Processing by QuotesController#update as HTML
Parameters: "utf8"=>"✓", "authenticity_token"=>"bVa+vhRayuPDhe5xkLcK2rm10zQ9oHvtDSZsKDhMBsdX/JDjf6uXsnIJ7gM/yP7Lt9E+aBGIR9WCoLU2uNhgVQ==", "quote"=>"issued_at"=>"12/11/2018 11:05 AM", "quote_line_item"=>"description"=>"QuoteLineItem description goes here...", "price"=>"800.00", "commit"=>"Save", "id"=>"62"
Quote Load (3.8ms) SELECT `quotes`.* FROM `quotes` WHERE `quotes`.`id` = 62 LIMIT 1
↳ app/controllers/quotes_controller.rb:127
(0.7ms) BEGIN
↳ app/controllers/quotes_controller.rb:53
(3.6ms) COMMIT
↳ app/controllers/quotes_controller.rb:53
Redirected to http://localhost:3000/quotes/62
Completed 302 Found in 44ms (ActiveRecord: 9.3ms)
Is there a reason this shouldn't be working?
Thanks.
ruby-on-rails ruby rails-activerecord nested-attributes
ruby-on-rails ruby rails-activerecord nested-attributes
edited Nov 12 '18 at 5:09
slehmann36
asked Nov 12 '18 at 4:36
slehmann36slehmann36
384418
384418
Can you please add log when you hit the update action?
– Vishal
Nov 12 '18 at 4:37
@Vishal I've added server logs for thequotes#update
action.
– slehmann36
Nov 12 '18 at 4:43
check your parameters forquote_line_item
it should bequote_line_items_attributes
. can you please try with this ` accepts_nested_attributes_for :quote_line_items, update_only: true ` and check how parameters are passing with this.
– Vishal
Nov 12 '18 at 4:45
@Vishal thanks for the suggestion. With your suggested updates, I receive the errorNo association found for name 'quote_line_items'. Has it been defined yet?
. The documentation shows that the model should be referenced in a singular form if the association is ahas_one
. Thanks
– slehmann36
Nov 12 '18 at 4:52
Okay, it should be onlyaccepts_nested_attributes_for :quote_line_item, update_only: true
, but you need to pass the parameters correctly. in form, try this<%= fields_for :quote_line_item, @quote.quote_line_item do |quote_line_item_fields| %>
– Vishal
Nov 12 '18 at 4:55
|
show 11 more comments
Can you please add log when you hit the update action?
– Vishal
Nov 12 '18 at 4:37
@Vishal I've added server logs for thequotes#update
action.
– slehmann36
Nov 12 '18 at 4:43
check your parameters forquote_line_item
it should bequote_line_items_attributes
. can you please try with this ` accepts_nested_attributes_for :quote_line_items, update_only: true ` and check how parameters are passing with this.
– Vishal
Nov 12 '18 at 4:45
@Vishal thanks for the suggestion. With your suggested updates, I receive the errorNo association found for name 'quote_line_items'. Has it been defined yet?
. The documentation shows that the model should be referenced in a singular form if the association is ahas_one
. Thanks
– slehmann36
Nov 12 '18 at 4:52
Okay, it should be onlyaccepts_nested_attributes_for :quote_line_item, update_only: true
, but you need to pass the parameters correctly. in form, try this<%= fields_for :quote_line_item, @quote.quote_line_item do |quote_line_item_fields| %>
– Vishal
Nov 12 '18 at 4:55
Can you please add log when you hit the update action?
– Vishal
Nov 12 '18 at 4:37
Can you please add log when you hit the update action?
– Vishal
Nov 12 '18 at 4:37
@Vishal I've added server logs for the
quotes#update
action.– slehmann36
Nov 12 '18 at 4:43
@Vishal I've added server logs for the
quotes#update
action.– slehmann36
Nov 12 '18 at 4:43
check your parameters for
quote_line_item
it should be quote_line_items_attributes
. can you please try with this ` accepts_nested_attributes_for :quote_line_items, update_only: true ` and check how parameters are passing with this.– Vishal
Nov 12 '18 at 4:45
check your parameters for
quote_line_item
it should be quote_line_items_attributes
. can you please try with this ` accepts_nested_attributes_for :quote_line_items, update_only: true ` and check how parameters are passing with this.– Vishal
Nov 12 '18 at 4:45
@Vishal thanks for the suggestion. With your suggested updates, I receive the error
No association found for name 'quote_line_items'. Has it been defined yet?
. The documentation shows that the model should be referenced in a singular form if the association is a has_one
. Thanks– slehmann36
Nov 12 '18 at 4:52
@Vishal thanks for the suggestion. With your suggested updates, I receive the error
No association found for name 'quote_line_items'. Has it been defined yet?
. The documentation shows that the model should be referenced in a singular form if the association is a has_one
. Thanks– slehmann36
Nov 12 '18 at 4:52
Okay, it should be only
accepts_nested_attributes_for :quote_line_item, update_only: true
, but you need to pass the parameters correctly. in form, try this <%= fields_for :quote_line_item, @quote.quote_line_item do |quote_line_item_fields| %>
– Vishal
Nov 12 '18 at 4:55
Okay, it should be only
accepts_nested_attributes_for :quote_line_item, update_only: true
, but you need to pass the parameters correctly. in form, try this <%= fields_for :quote_line_item, @quote.quote_line_item do |quote_line_item_fields| %>
– Vishal
Nov 12 '18 at 4:55
|
show 11 more comments
1 Answer
1
active
oldest
votes
Try referencing quote_form
before your fields_for
:
<%= form_for @quote do |quote_form| %>
...
<%= quote_form.fields_for :quote_line_item do |quote_line_item_fields| %>
# ^ <- Add here
...
<% end %>
<% end %>
After updating this, check that the parameters being passed to quotes#edit
are nested:
i.e: "quote"=>"issued_at"=>"12/11/2018 11:05 AM", "quote_line_item"=>"description"=>"Line item description goes here...", "price"=>"200.00", "id"=>"63"
1
That was it, thanks for your answer.
– slehmann36
Nov 12 '18 at 6:50
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256029%2fvalues-for-nested-fields-not-saving-without-error-rails-5-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try referencing quote_form
before your fields_for
:
<%= form_for @quote do |quote_form| %>
...
<%= quote_form.fields_for :quote_line_item do |quote_line_item_fields| %>
# ^ <- Add here
...
<% end %>
<% end %>
After updating this, check that the parameters being passed to quotes#edit
are nested:
i.e: "quote"=>"issued_at"=>"12/11/2018 11:05 AM", "quote_line_item"=>"description"=>"Line item description goes here...", "price"=>"200.00", "id"=>"63"
1
That was it, thanks for your answer.
– slehmann36
Nov 12 '18 at 6:50
add a comment |
Try referencing quote_form
before your fields_for
:
<%= form_for @quote do |quote_form| %>
...
<%= quote_form.fields_for :quote_line_item do |quote_line_item_fields| %>
# ^ <- Add here
...
<% end %>
<% end %>
After updating this, check that the parameters being passed to quotes#edit
are nested:
i.e: "quote"=>"issued_at"=>"12/11/2018 11:05 AM", "quote_line_item"=>"description"=>"Line item description goes here...", "price"=>"200.00", "id"=>"63"
1
That was it, thanks for your answer.
– slehmann36
Nov 12 '18 at 6:50
add a comment |
Try referencing quote_form
before your fields_for
:
<%= form_for @quote do |quote_form| %>
...
<%= quote_form.fields_for :quote_line_item do |quote_line_item_fields| %>
# ^ <- Add here
...
<% end %>
<% end %>
After updating this, check that the parameters being passed to quotes#edit
are nested:
i.e: "quote"=>"issued_at"=>"12/11/2018 11:05 AM", "quote_line_item"=>"description"=>"Line item description goes here...", "price"=>"200.00", "id"=>"63"
Try referencing quote_form
before your fields_for
:
<%= form_for @quote do |quote_form| %>
...
<%= quote_form.fields_for :quote_line_item do |quote_line_item_fields| %>
# ^ <- Add here
...
<% end %>
<% end %>
After updating this, check that the parameters being passed to quotes#edit
are nested:
i.e: "quote"=>"issued_at"=>"12/11/2018 11:05 AM", "quote_line_item"=>"description"=>"Line item description goes here...", "price"=>"200.00", "id"=>"63"
answered Nov 12 '18 at 6:49
JosephA91JosephA91
547
547
1
That was it, thanks for your answer.
– slehmann36
Nov 12 '18 at 6:50
add a comment |
1
That was it, thanks for your answer.
– slehmann36
Nov 12 '18 at 6:50
1
1
That was it, thanks for your answer.
– slehmann36
Nov 12 '18 at 6:50
That was it, thanks for your answer.
– slehmann36
Nov 12 '18 at 6:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256029%2fvalues-for-nested-fields-not-saving-without-error-rails-5-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you please add log when you hit the update action?
– Vishal
Nov 12 '18 at 4:37
@Vishal I've added server logs for the
quotes#update
action.– slehmann36
Nov 12 '18 at 4:43
check your parameters for
quote_line_item
it should bequote_line_items_attributes
. can you please try with this ` accepts_nested_attributes_for :quote_line_items, update_only: true ` and check how parameters are passing with this.– Vishal
Nov 12 '18 at 4:45
@Vishal thanks for the suggestion. With your suggested updates, I receive the error
No association found for name 'quote_line_items'. Has it been defined yet?
. The documentation shows that the model should be referenced in a singular form if the association is ahas_one
. Thanks– slehmann36
Nov 12 '18 at 4:52
Okay, it should be only
accepts_nested_attributes_for :quote_line_item, update_only: true
, but you need to pass the parameters correctly. in form, try this<%= fields_for :quote_line_item, @quote.quote_line_item do |quote_line_item_fields| %>
– Vishal
Nov 12 '18 at 4:55