私は単純な言葉でしたい:入力値が変更されたら、私はこの値をdbに入れます。 いくつかのajaxを追加したいと思います。私はこれをしたい: 私は私の入力値(focusout)を変更するとき、私は私の方法は次のようになり、取得-parametrを使用して、いくつかのメソッドを呼び出します。レールのショッピングカートにいくつかのajaxを追加するには?
def update_quantity
@cart = current_cart
@line_item = LineItem.find(params[:id])
respond_to do |format|
if @line_item.update_attribute(:quantity, params[:quantity]) #&& @cart.id == params[:cart]
format.html { redirect_to(@line_item, :notice => 'Line item was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @line_item.errors, :status => :unprocessable_entity }
end
end
end
これはテスト作業で、それは多分持っているので、
%p
= line_item.art_name
= line_item.ART_ID
= line_item.art_code
×
.cart-quantity
= line_item.quantity
%input{ :class => "quantity", :value => line_item.quantity }
= link_to "обновить", :controller => "line_items", :action => "update_quantity", :id => line_item.id, :quantity => line_item.quantity, :cart => @cart.id
= line_item.total_price
ご覧のように、私がしたい:入力フォーカスが出ているとき、私は新しい隠されたリンクを取得し、それを呼び出すと、上部書かれているメソッドを呼び出しているいくつかの悪いソリューション、そして私の見解は次のようになります。 私は何をする必要がありますか?どのファイルを作成するのか、どこでどのようにこれを行うのですか?
私は単純な言葉でしたい:入力値が変更されたら、私はこの値をdbに入れます。
私がやりたいすべてをブロック:html要素ののonblurフィールドを使用します単純な言葉で:入力値が変更されると、私はこの値をdbに入れます。 – byCoder