best_in_place with has_many association

时间:2014-08-06 13:13:11

标签: ruby-on-rails best-in-place

我想将best_in_place用于像这样的has_many_association:

<% @offer.locations.each do |location| %>
  <%= best_in_place location, :name, :path => offer_path(@offer) %>
<% end %>

offers_controller.rb

  def update
    if @offer.update(offer_params)
      respond_to do |format|
        format.html { render :edit }
        format.json   { respond_with_bip(@offer) }
      end
    else
      render :edit
    end
  end


private

  def offer_params
    params.require(:offer).permit(:template_id, :client_id, :partner_id, :status,
    locations_attributes: [:id, :name, :address, :_destroy,
    surfaces_attributes: [:id, :size, :_destroy,
    services_attributes: [:id, :name, :price, :unit, :description, :service_id,    :_destroy]
      ]])
  end

  def find_offer
   @offer = Offer.find(params[:id])
  end

但是当我尝试编辑位置字段时,位置ID与要约的ID具有相同的ID。 我也使用cocoon gem作为嵌套表单。

有任何帮助吗?谢谢!

0 个答案:

没有答案