繁体   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