[Rails] Re: Convert javascript array to ruby array

2008-09-09 Thread Frederick Cheung
On Sep 9, 10:38 pm, David <[EMAIL PROTECTED]> wrote: > So it turns out the call myArray.toJSON() only converts the javascript > array myArray to a string.  I have implemented a work around parse to > convert the string into an array, but i was wondering if anyone knows > of a JSON method to conv

[Rails] Re: Convert javascript array to ruby array

2008-09-09 Thread Joshua Abbott
I may be wrong, but since JS is a client side language and Ruby is a server side language, won't all of the ruby code have been parsed before the JS array is ever even created? -- Josh David wrote: > So it turns out the call myArray.toJSON() only converts the javascript > array myArray to a st

[Rails] Re: Convert javascript array to ruby array

2008-09-09 Thread David
So it turns out the call myArray.toJSON() only converts the javascript array myArray to a string. I have implemented a work around parse to convert the string into an array, but i was wondering if anyone knows of a JSON method to convert directly to a ruby array. Maybe this would be faster? On

[Rails] Re: Convert javascript array to ruby array

2008-09-09 Thread David
Yea, you were right, its been a long daybut i have finally figured it out. Thanks for your help. For anyone who is trying to convert a javascript array to a ruby array and pass the array to the controller you can follow this advice: create a javascript function that returns the array with th

[Rails] Re: Convert javascript array to ruby array

2008-09-09 Thread Frederick Cheung
On Sep 9, 9:03 am, David <[EMAIL PROTECTED]> wrote: > This is the line that caused the error: <%= link_to_remote 'Click > me', :url => {:controller => "appointments", :action => > "array"}, :with => "test"%>.  These are the lines that follow the No, that line didn't cause the error. That piece

[Rails] Re: Convert javascript array to ruby array

2008-09-09 Thread David
This is the line that caused the error: <%= link_to_remote 'Click me', :url => {:controller => "appointments", :action => "array"}, :with => "test"%>. These are the lines that follow the error: TypeError (exception object expected): /app/controllers/appointments_controller.rb:72:in `raise'

[Rails] Re: Convert javascript array to ruby array

2008-09-09 Thread Frederick Cheung
On Sep 9, 6:22 am, David <[EMAIL PROTECTED]> wrote: > okay, thanks for the heads up.  The error says, TypeError (exception > object expected).  Not sure what this means, do you have any idea? > Usually it means you tried to raise something that isn't an exception, but without a backtrace or seei

[Rails] Re: Convert javascript array to ruby array

2008-09-08 Thread David
okay, thanks for the heads up. The error says, TypeError (exception object expected). Not sure what this means, do you have any idea? On Sep 8, 6:45 pm, Frederick Cheung <[EMAIL PROTECTED]> wrote: > On 9 Sep 2008, at 02:42, David wrote: > > > > > > > Yea, I am trying to just use the link_to_rem

[Rails] Re: Convert javascript array to ruby array

2008-09-08 Thread Frederick Cheung
On 9 Sep 2008, at 02:42, David wrote: > > Yea, I am trying to just use the link_to_remote helper now, but aside > from converting the array and using JSON, I can't even get the > link_to_remote to route now. I am using: > > <%= link_to_remote 'Click me', :url => {:action => "update"}, :with > =

[Rails] Re: Convert javascript array to ruby array

2008-09-08 Thread David
Yea, I am trying to just use the link_to_remote helper now, but aside from converting the array and using JSON, I can't even get the link_to_remote to route now. I am using: <%= link_to_remote 'Click me', :url => {:action => "update"}, :with => 'test' %> and the only action that works successf

[Rails] Re: Convert javascript array to ruby array

2008-09-08 Thread Frederick Cheung
On 8 Sep 2008, at 22:54, David wrote: > > Sorry, that ajax.request method should be a put, so: > > new Ajax.Request('/appointments/array/', > {method:'post',postBody:"'data='+myArray.toJSON"}); > If you're just posting json then you shouldn't that data= (and you look like you're writing a link

[Rails] Re: Convert javascript array to ruby array

2008-09-08 Thread David
Sorry, that ajax.request method should be a put, so: new Ajax.Request('/appointments/array/', {method:'post',postBody:"'data='+myArray.toJSON"}); On Sep 8, 2:52 pm, David <[EMAIL PROTECTED]> wrote: > Hey can anyone help me convert a javascript array into a ruby array. > Ive been struggling with