[Ajax on Rails]How to pass an object via param

I’m trying to pass an object as a parameter on a link_to_remote. What
I do is pretty simple:
link_to_remote ‘Insert subquestion’, :url => {:action =>
‘add_subquestion’, :question => @question}, :update => ‘’, :method
=> :get

But, obviously, what I get is a string which has the address of the
object. Can I “translate” this string back to the object? Is there a
better way to pass an object as a param?

But it’s a new object. It doesn’t have any id yet.
But I think I have a solution. Instead of passing an id, adress or
object_id, I’ll pass it’s subquestion’s array length. Then all I have
to do is put one more subquestion.
Thank you, anyway.

On Jan 13, 7:04Â pm, Yuri [email protected] wrote:

I’m trying to pass an object as a parameter on a link_to_remote. What
I do is pretty simple:
link_to_remote ‘Insert subquestion’, :url => {:action =>
‘add_subquestion’, :question => @question}, :update => ‘’, :method
=> :get

But, obviously, what I get is a string which has the address of the
object. Can I “translate” this string back to the object?

No. There is no way I know of to translate an address back into an
actual object (although writing a ruby extension to do that is
probably possible). Anyway, the request may have gone to a different
mongrel or the original object may have been garbage collected

Is there a
better way to pass an object as a param?

pass its id

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs