更改jeditable rails gem中的更新操作

时间:2011-05-13 09:13:40

标签: ruby-on-rails model action jeditable

我希望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"}) |

1 个答案:

答案 0 :(得分:1)

要执行您想要的操作,您必须编辑路径文件以创建指向该操作的路径。例如:

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
相关问题