Hi, I tried to insert rows of the same table from different forms in different pages. Example: user table has name, address, telephone number and hobbies. I have two pages with one form in each page. One form in the page has name and address fields while the other form in the other page has telphone number and hobbies fields. All of the fields cannot be null. I need to be able to post these fields from those two different forms. Can anyone please help me to achieve this ? Thanks, user splash -- 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 -~----------~----~----~----~------~----~------~--~---
felipekk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jan-11 08:46 UTC
Re: Insert rows of the same table from different forms
Considering that the data from the first form cannot be saved yet because of validation, all you need to do is to add hidden fields that relate to the attributes from the first form. Say the first form is to change name and the second to change address, you would add in the second a hidden field that uses @user.name. This will work if you are using @user = User.new(params[:user]) to initiate the user object on every form. It will get nasty when you try to validate the user though, cause he will go trough all forms without errors and on the last one might get an error that "Name" (from first form) is blank. My advice is to add all fields who need to be present for the model to pass validation on the first form. Considering a user object, this would usually be username, password and email. Then you show the user some reminders to update his address in case he have an empty one. Remember, make the "sign up" forms short and quick. Ask the user to fill additional but not that critical data later... On Jan 10, 7:41 pm, user splash <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > I tried to insert rows of the same table from different forms in > different pages. > > Example: user table has name, address, telephone number and hobbies. > I have two pages with one form in each page. One form in the page has > name and address fields while the other form in the other page has > telphone number and hobbies fields. All of the fields cannot be null. I > need to be able to post these fields from those two different forms. > > Can anyone please help me to achieve this ? > > Thanks, > user splash > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
felipekk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Considering that the data from the first form cannot be saved yet > because of validation, all you need to do is to add hidden fields that > relate to the attributes from the first form. > > Say the first form is to change name and the second to change address, > you would add in the second a hidden field that uses @user.name. > > This will work if you are using @user = User.new(params[:user]) to > initiate the user object on every form. > > It will get nasty when you try to validate the user though, cause he > will go trough all forms without errors and on the last one might get > an error that "Name" (from first form) is blank. > > My advice is to add all fields who need to be present for the model to > pass validation on the first form. Considering a user object, this > would usually be username, password and email. Then you show the user > some reminders to update his address in case he have an empty one. > Remember, make the "sign up" forms short and quick. Ask the user to > fill additional but not that critical data later... > > On Jan 10, 7:41?pm, user splash <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Hi, So what the previous posting means is for me to post the fields from the first form to the second form in hidden fields? And does this work for update as well? Thanks, user splash -- 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 -~----------~----~----~----~------~----~------~--~---
> Hi, > > So what the previous posting means is for me to post the fields from the > first form to the second form in hidden fields? And does this work for > update as well? > > Thanks, > user splashTo add on to the previous postings, I have to create 100 over rows. Won''t it over load the form by hidding these fields? And I would love to know how can I insert more than one rows into a column all at the same time? Thanks, user splash -- 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 -~----------~----~----~----~------~----~------~--~---
felipekk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jan-11 18:57 UTC
Re: Insert rows of the same table from different forms
Now I don''t understand you anymore. My examples were for a simple user form, where you edit basic stuff like name on the first form and address on the second one. And I understood that they were "sequential", as in a 2 step thing. If they are not sequential then this does not apply. I need you to explain better, with real code if possible what the model is and what data you want to change on the first form and what data you want to change on the second form. On Jan 11, 1:52 am, fries 88 <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > > > So what the previous posting means is for me to post the fields from the > > first form to the second form in hidden fields? And does this work for > > update as well? > > > Thanks, > > user splash > > To add on to the previous postings, I have to create 100 over rows. > Won''t it over load the form by hidding these fields? And I would love to > know how can I insert more than one rows into a column all at the same > time? > > Thanks, > user splash > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
There are a couple options.. Option 1: have the entire form on one page, where you put the form on separate tabs. The tabs would be hidden + selectable via DHTML + Javascript Option 2: User.save_without_validation, storing the user id either in session or flash, or params, or have a hidden_field_tag which carries the user id along with each form. On Jan 10, 10:41 pm, user splash <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > I tried to insert rows of the same table from different forms in > different pages. > > Example: user table has name, address, telephone number and hobbies. > I have two pages with one form in each page. One form in the page has > name and address fields while the other form in the other page has > telphone number and hobbies fields. All of the fields cannot be null. I > need to be able to post these fields from those two different forms. > > Can anyone please help me to achieve this ? > > Thanks, > user splash > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Gammons wrote:> There are a couple options.. > > Option 1: > have the entire form on one page, where you put the form on separate > tabs. The tabs would be hidden + selectable via DHTML + Javascript > > Option 2: > User.save_without_validation, storing the user id either in session or > flash, or params, or have a hidden_field_tag which carries the user id > along with each form. > > On Jan 10, 10:41 pm, user splash <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Hi, The forms I am going to create might not be in step 1 step 2 sequence. As user can skip step 1 or 2 and move directly to step 3 then come back to do the steps he/she has skipped. Thanks, fries 88 -- 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 -~----------~----~----~----~------~----~------~--~---
fries 88 wrote:> Gammons wrote: >> There are a couple options.. >> >> Option 1: >> have the entire form on one page, where you put the form on separate >> tabs. The tabs would be hidden + selectable via DHTML + Javascript >> >> Option 2: >> User.save_without_validation, storing the user id either in session or >> flash, or params, or have a hidden_field_tag which carries the user id >> along with each form. >> >> On Jan 10, 10:41 pm, user splash <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > > > Hi, > > The forms I am going to create might not be in step 1 step 2 sequence. > As user can skip step 1 or 2 and move directly to step 3 then come back > to do the steps he/she has skipped. > > Thanks, > fries 88Hi, Sorry if I sound confusing. What I am required to do here is to create a new user. There are three pages here. - Page 1: save username and password into user table - Page 2: save address, telephone number and gender into user table - Page 3: save hobbies and favourites into user_info table The user does not have to browse around these pages in sequence. I have tried many ways and have yet to get this working. Anyone please, how can I acheive this. Thanks, fries 88 -- 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 -~----------~----~----~----~------~----~------~--~---
> Hi, > Sorry if I sound confusing. What I am required to do here is to create > a new user. There are three pages here. > - Page 1: save username and password into user table > - Page 2: save address, telephone number and gender into user table > - Page 3: save hobbies and favourites into user_info table > > The user does not have to browse around these pages in sequence. I have > tried many ways and have yet to get this working. Anyone please, how can > I acheive this. > > Thanks, > fries 88Sorry I miss out this part: All the fields in user table cannot be null -- 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 -~----------~----~----~----~------~----~------~--~---
fries 88 wrote:>> Hi, >> Sorry if I sound confusing. What I am required to do here is to create >> a new user. There are three pages here. >> - Page 1: save username and password into user table >> - Page 2: save address, telephone number and gender into user table >> - Page 3: save hobbies and favourites into user_info table >> >> The user does not have to browse around these pages in sequence. I have >> tried many ways and have yet to get this working. Anyone please, how can >> I acheive this. >> >> Thanks, >> fries 88 > > > Sorry I miss out this part: > All the fields in user table cannot be nullHi, I have tried the secong option suggested by Gammons and it still cant work. I dont understand the first option. Can someone please further explain or provide another option to this problem? Thanks, fries 88 -- 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 -~----------~----~----~----~------~----~------~--~---