I think if you want to redirect, you need to do a plain request--that is, drop 
the ajax & just do link_to.

But you should be able to save to the db from an ajax request.  What are you 
doing to save to the db & how do you know it's not working?  If there's an 
error, what is it?

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
David
Sent: Friday, September 19, 2008 3:19 PM
To: Ruby on Rails: Talk
Subject: [Rails] Saving to the database using link_to_remote?


I am attempting to save a javascript array that has collected clicks from the 
user into the database using link_to_remote.  I am new to ajax, so I do not 
know all the details but I have been told that in order to get the javascript 
array from the client side to the server side I must make an ajax request.  The 
ajax helper I am using is
link_to_remote:

<%= link_to_remote 'Click me', :url => {:action => "array"}, :with => 
"'data='+test()"%>

This works up until trying to save the array to the database.  It passes the 
array, which is the result of the javascript function
test() to the action array and I am able to convert to ruby.  However, I am 
unable to save anything to the database, or redirect to any other action.  I am 
wondering, firstly, Is link_to_remote even the appropriate ajax helper, and if 
so, How can I save this information to the database in the array action as seen 
above?  Thanks, Dave 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to