簡體   English   中英

更改可編輯Rails Gem中的更新操作

[英]Change update action in jeditable rails gem

我希望editable_field在控制器中調用自定義操作,而不是調用“ update”方法。

這是我在haml文件中的代碼(我在:action屬性中寫了我想調用的動作):

editable_field(today_clockings[col-1], :clocking, |
   {:update_url => resource_clocking_path(@resource, today_clockings[col-1]), :action => "update_ts_clocking"}) |

要執行您想要的操作,您將必須編輯路徑文件以創建操作的路徑。 例如:

routes.rb中

match "today_clocking/update_ts_clocking" => 'today_clocking#update_ts_clocking', :as => :update_ts_clocking

然后在您看來

<%= editable_field(today_clockings[col-1], :clocking, {:update_url => update_ts_clocking_path) %>

然后, today_clockings_controller.rb將類似於:

def update_ts_clocking
    # Update model here with params[:today_clocking][:clocking]
end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM