Creating new record through fields for within Rails 4

7 Views Asked by At

I'm attempting to create a new oil production within the production information page. The fields are appearing but I am unable to get the oil production to save. Any help is appreciated

Productioninfos_controller.rb

  def index
      @productioninfos = Productioninfo.all
  end
  def new
     @productioninfo = Productioninfo.new
  end 
  def productioninfo_params
     params.require(:productioninfo).permit(:firstproduction, :lastproduction, :numberofcompl, :totaldepth, :productionzone, oilproductioninfos_attributes: [:id, :oilcum, :avgbpmlastsixmonths, :avgbpodlastsixmonths])
  end

Productioninfo.rb (model)

has_many :oilproductioninfos
accepts_nested_attributes_for :oilproductioninfo, :allow_destroy => :true,  :reject_if => :blank

Oilproductioninfo.rb (model)

belongs_to :productioninfo

Productioninfos_form.html.erb

<%= f.fields_for :oilproductioninfos do |ff| %>

  <div>
    <%= ff.label :oilcum %>
    <%= ff.text_field :oilcum %>

    <%= ff.label :avgbpmlastsixmonths %>
    <%= ff.text_field :avgbpmlastsixmonths %>

    <%= ff.label :avgbpodlastsixmonths %>
    <%= ff.text_field :avgbpodlastsixmonths %>
  </div>
0

There are 0 best solutions below