Hello, I have following doubts and have spent many days trying to crack them without luck, please help : 1. 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 ? 2. 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. 3. Is there a way to send a hash via the link_to tag ? Thanks atul -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 27, 2007, at 6:29 AM, Atul Gupta wrote:> > Hello, > > I have following doubts and have spent many days trying to crack them > without luck, please help : > > 1. 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 ? > > 2. 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. > > 3. Is there a way to send a hash via the link_to tag ? > > Thanks > > atulI 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. Peace, Phillip --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for a solution Phillip, anyway, is there a way to include more than one value in the link_to tag ? atul -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 27, 2007, at 8:19 AM, Atul Gupta wrote:> > Thanks for a solution Phillip, anyway, is there a way to include more > than one value in the link_to tag ?Well, you can do basically the same thing with link_to as you do with redirect_to, and that is <%= link_to "My link", :controller => ''my_controller'', :action => ''my_action'', :id => 1, :my_param_1 => ''good-bye'', :my_param_2 => ''cruel world!'' %> and that will result in a url like http://localhost:3000/my_controller/my_action/1?my_param_1=good- bye&my_param_2=cruel+world%21 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 --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Phillip Koebbe, Thanks a lot, that solved my problem. atul -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---