1
一個的link_to我有控制器:Rails的 - 如何建立這使該控制器的更新
class GroupRequestsController < ApplicationController
def update
@group_request = GroupRequest.find(params[:id])
respond_to do |format|
if @group_request.update_attributes(params[:group_request])
format.js
else
format.js
end
end
end
在我看來,我有:
<button type="button" class="button positive tiny">Add</button>
<button type="button" class="button tiny">Ignore</button>
我怎樣才能讓在點擊這些按鈕,做一個遠程調用控制器的更新方法作爲決定參數的添加或忽略?
謝謝
謝謝我對錶單標記的想法有點驚訝。好奇的是,這真的是最好的方法?這將是很多頁面中的表單標籤。使用遠程鏈接不好嗎? – AnApprentice 2011-05-25 19:59:47
你不能用鏈接將數據真正發送到服務器,你只能在查詢字符串中發送數據。在頁面上顯示大量表單沒有任何問題。定位標記是GET和DELETE請求哪些表單標記是POST和PUT請求。 – 2011-05-25 22:56:46