简体   繁体   中英

Change update action in jeditable rails gem

I would like that the editable_field call a custom action in my controller instead to call the 'update' method.

This is my code in the haml file (i write the action i want to invoke in the :action attribute):

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

To do what you want, you would have to edit your routes file to create a route to the action. For example:

In routes.rb

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

Then in your view :

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

Then the today_clockings_controller.rb would be something like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM