【问题标题】:Change update action in jeditable rails gem在 jeditable rails gem 中更改更新操作
【发布时间】:2011-05-13 09:13:39
【问题描述】:

我希望 editable_field 在我的控制器中调用自定义操作,而不是调用“更新”方法。

这是我在 haml 文件中的代码(我在 :action 属性中编写了我想要调用的操作):

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

【问题讨论】:

    标签: ruby-on-rails model action jeditable


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-08
      相关资源
      最近更新 更多