Reputation: 103
What is the best way to take a serialized list in JavaScript and save it to an instance variable array(or hash) in Rails?
Upvotes: 0
Views: 2267
Reputation: 31
Here are some options on how to do this:
http://www.activars.com/2009/04/13/pass-javascript-variables-to-rails-controller/
Upvotes: 1
Reputation: 3417
You could try setting a hidden field with the list values and then setup a controller action to handle the data.
Upvotes: 0
Reputation: 19635
Javascript code runs on the client, and your Rails code runs on the server, so there's no way to directly pass your Javascript data to Rails. Instead you'd likely have to set up a controller to specifically handle an HTTP POST with your serialized data as the payload.
Upvotes: 2