I am using some tutorial to create a dynamic form in which i should be able to add json object array of amounts
.
i should get this params from form
quote_amounts: [
{"kind"=>"website", "label"=>"Website", "amount"=>10000.0},
{"kind"=>"website_review", "label"=>"Website Review", "amount"=>12000.0}
]
I have created created the controller in this way
def create
@quote.assign_attributes(quote_params)
if @quote.save
@quote.submit_quote
@name = @quote.contact.user.display_name
redirect_to confirm_form_submission_path
else
render :new
end
end
and
def quote_params
params.require(:vendor_quote).permit(:notes, quote_amounts: [])
end
and I have created this form
<%= f.number_field :amount, min: 0, prepend: '$', required: true %>
<%= f.text_field :label, required: true %>
<%= f.text_field :kind, required: true %>
<%= f.text_area :notes %>
<%= f.submit "Submit quote", class: "btn btn-info btn-lg btn-block btn-rounded text-uppercase" %>
by this i am getting this error
undefined method `amount' for :amount
and please tell me that how to add 'add more' button so i can add multiple quote_amounts and save it into one json array object in single form.
Aucun commentaire:
Enregistrer un commentaire