[Rails] Re: Pass ruby array with Ajax.Request

2009-01-16 Thread Jeremy Olliver
Hi David, That depends on what you need the AR objects for, if they are records that already exist in your database and your controller only need the reference to them, you'ld be better off passing just the ids (and type if they differ) and having your controller action fetch the records. If the

[Rails] Re: Pass ruby array with Ajax.Request

2009-01-15 Thread David
So Ive decided it might be better to take a step backwards and explain what I am trying to do to because there may be a better way of doing it. I have an array of hashes and each hash correlates to an active record object. Now what I need to do is pass this array to a controller action using Aja

[Rails] Re: Pass ruby array with Ajax.Request

2009-01-15 Thread David
It seems like there is a better way to pass an array with Ajax.request into a controller and have it interpreted into a ruby array. Using link_to_remote, you are able to pass an array using :with -> <%= link_to_remote 'Click me', :url => {:action => "array"}, :with => "'data='+test()", :update =

[Rails] Re: Pass ruby array with Ajax.Request

2009-01-15 Thread David
Nevermind, Its seems to be working now. This is what shows up in the console: "data"=>"[object Object]" and I am wondering, do I have to convert this json array back to ruby to use it and if so how do I do that? On Jan 15, 3:56 pm, David wrote: > I tried this, but I still get an error: > > u

[Rails] Re: Pass ruby array with Ajax.Request

2009-01-15 Thread David
I tried this, but I still get an error: undefined method `toJSON' for []:Array On Jan 15, 5:44 am, "Brandon Keepers" wrote: > On Thu, Jan 15, 2009 at 8:05 AM, David wrote: > > > I am hoping someone can please help me with this.  I am trying to pass > > an array using Ajax.Request and cannot ge

[Rails] Re: Pass ruby array with Ajax.Request

2009-01-15 Thread Brandon Keepers
On Thu, Jan 15, 2009 at 8:05 AM, David wrote: > > I am hoping someone can please help me with this. I am trying to pass > an array using Ajax.Request and cannot get it working. This is what I > have so far: > > @data is a ruby array > > new Ajax.Request( '/users/test', { > parameters: