mercredi 8 mars 2017

Rails - Update attributes with best in place gem

Using best in place to update a attribute in a Order form rails spit out undefined methodupdate_attributes' for #`

the form is not on a update action but in a sold action, so the form must be inside of a update action?

          <%= best_in_place order, :track_number, :as => :input, :nil => "Track code", :url => sold_order_path(order)%> 



        Mark as:

            <%= link_to "Sent",  sent_order_path(order), :class => 'btn btn_small' %>






def sold
    @q = Order.where('seller_id = ? and status = ?', current_vitrine.id, params[:status] || Order.statuses[0]).ransack(params[:q])
    @orders = @q.result(distinct: true).paginate(page: params[:page], per_page: 22)

 @order = Order.find_by_id(params[:id]) 


     respond_to do |format|
      if Order.where('seller_id = ? and status = ?', current_vitrine.id, params[:status] || Order.statuses[0]).update_attributes(params[:order])
        format.html { redirect_to :back, notice: 'Comment was successfully updated.' }
        format.json { respond_with_bip(@order) }
      else
        format.html { render action: 'sold' }
        format.json { respond_with_bip(@order) }
      end
    end

  end

Aucun commentaire:

Enregistrer un commentaire