I have following doubts and have spent many days trying to crack them
without luck, please help :
I have a form with pure text fields at the top and a table with
multiple rows with data derived from many objets of a class below that.
I want to provide a link in each row which takes me to a new form. I
can pass the id of each row via the link_to tag and read the value
successfully in the next form.
But how do I include the value of the text boxes in each row ?
Can I send an object with several attibutes in the link-to tag, say
the object name is ‘book’, then how do i read it as an object in the
next form, params[:book] didnot work.
Is there a way to send a hash via the link_to tag ?
can pass the id of each row via the link_to tag and read the value
Thanks
atul
I have a somewhat similar situation in which I have a list of
“headers”. For example’s sake, lets call it a list of people and the
header includes a name and a date of birth. When the header is
clicked, I display a form that is populated with details about the
person. I do this with a variation of link_to_remote. Basically,
you make an AJAX call to the server passing the id of the object you
want to operate on. The controller action then gathers all the data
necessary and renders a partial, which is displayed in the area you
want it. If you use link_to_remote “properly”, then one of the
parameters is :update => “dom_id_of_element_to_update” and all you
have to do in the controller is a render :partial. I, however, being
the renegade (or idiot, as the case may be) that I am, call a
Javascript function which makes the AJAX call and the controller uses
render :update to refresh the element. [Ooh, I can hear all the boos
now. :)]
That should get you going. If not, feel free to ask more.
If you don’t like fat URLs, the other option is to use :method
=> :post, which I think you can do with link_to. I’ll leave
figuring that part out to you
Peace,
Phillip
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.