Ted Battreall
2006-Aug-10 17:33 UTC
[Rails] Updating a database record using Javascript variables
I need to update a record in a table based on a event that occurs in the View. I believe the update action should occur in the controller. I think I need to call the controller action from the View and pass data that is stored in a Javascript variables as a parameter, but I am not sure how to do it. Can someone show me how I should be doing this? Below is a simplified version of the code I am trying to produce: View: <script type="text/javascript"> <!-- function my_Func() { varx = dd.obj.x; // Not sure how to call the controller in the next line <%= render_component :action => ''updatex'', :xvalue => varx %> } --> </script> Controller: Def updatex Person.update(10, {:xvalue => params[:xvalue]}) end -- Posted via http://www.ruby-forum.com/.