Rails fields_for form not showing up, nested form

Even the question is quite old, but you are missing the new that is crucial to this question. The methods destroy and create doesn't have anything with this issue. If you have a new method, which looks something like this:

class TreatmentsController < ApplicationController
  def new
    @patient = Patient.new
  end
end

Then the solution would be do modify the new method to "build" the paintings like this:

class TreatmentsController < ApplicationController
  def new
    @patient = Patient.new
    @patient.paintings.build
  end
end

Try doing following in new action in controller

@patient.treatments.build

Check out build_association part http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-belongs_to

You should also read about nested attributes. Use those for reference http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html


Please try

= f.fields_for :paintings, Painting.new do |p|