rails 3.2 Ruby 2.1.5
I am trying to have a single form for a ticket, that includes a number of sections.
One of the sectios is called customer_info
In the app/views/tickets/show.html.slim, I have:
= render 'tickets/sections/customer_info', locals: { customer_info: CustomerInfo.new, ticket: @ticket }
and in my app/views/tickets/sections/_customer_info.html.slim, I have:
= form_for customer_info do |f|
- f.hidden_field :ticket_id, :value => ticket.id
.form-horizontal-column.customer-info
.form-group
= f.label :pre_tax_total
= f.text_field :pre_tax_total, maxlength: 50
.form-group
= f.label :post_tax_total
= f.text_field :post_tax_total, maxlength: 50
.actions = f.submit 'Save'
.clear
When the app attempts to render the customer_info form, I get the following error message:
undefined method `model_name' for NilClass:Class
When it hits the first line in the form:
= form_for customer_info do |f|
Any idea how to do this?
Try to change the render code from
= render 'tickets/sections/customer_info', locals: { customer_info: CustomerInfo.new, ticket: @ticket }
to
= render partial: 'tickets/sections/customer_info', locals: { customer_info: CustomerInfo.new, ticket: @ticket }
Always remember to add partial
if locals
is used.