I have a relationship where a merchant can have multiple payments. I am
posting payments to a merchant and there is a validation error. Payment
object does have the values retained. Can some one help me fix the
issue?
View Code->
<%= @merchant.name %>
<%= form_for([@merchant, @merchant.payments.build]) do |f| %>
<% if @payment.errors.any? %>
<%= pluralize(@payment.errors.count, "error") %> prohibited this
payment from being saved:
<% @payment.errors.full_messages.each do |msg| %>
<%= msg %>
<% end %>
<% end %>
test
// Prints the values correctly
<%= @payment.credit_card_number %>
<%= @payment.zip %>
<%= @payment.country %>
On Mon, Dec 10, 2012 at 3:42 PM, rubyrookie [email protected] wrote:
Thank you very much. I will read up on the difference. Sorry should have
bolded my answers.
No worries. If you’re looking for the difference, @payment (as you
already
know) uses the same
record as the one you have in your controllers. If you use @merchant.payments.build, you’re
creating a new payment record which does not contain the values
submitted
by the user
It would’ve helped if you somehow bolded your answers. anyway, you should
View Code->
// Prints the values correctly
<%= f.label :address_line_2 %>
respond_to do |format|
end
On Mon, Dec 10, 2012 at 3:45 PM, Jim Ruther N. [email protected]
wrote:
already know) uses the same
record as the one you have in your controllers. If you use @merchant.payments.build, you’re
creating a new payment record which does not contain the values submitted
by the user
regarding your question on the field_error_proc. read this one and
please
don’t email users directly
values. Payment object has the values though.
fixed.
<%= form_for([@merchant, @payment]) do |f| %>
am posting payments to a merchant and there is a validation error. Payment