(Start disclaimer) New to ruby, new to rails, haven''t programmed since high school. (End disclaimer) I am working on a personal project which I can use to track my golf scores and progress but am having difficult keeping a running count of the amount of holes played. The app should work like this: 1. User starts the round - OK 2. Hole number is set to 1 - OK 3. User submits the first hole - OK 3a. Hole number is saved as 1 - OK 3b. Hole number increases by 1 - NOT OK 4. Redirect back to new - OK Repeat until hole number = 18 How can I create a variable which will store the hole number for the number of user inputs? Or should I write a loop which runs the input form # times? Thanks for any advice. (The basic code I am working off of is a (very) slightly modified scaffold) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You can store it in a session variable to keep track across requests session[:hole_number] = hole_number -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Dan Ci wrote:> (Start disclaimer) New to ruby, new to rails, haven''t programmed since > high school. (End disclaimer) > > I am working on a personal project which I can use to track my golf > scores and progress but am having difficult keeping a running count of > the amount of holes played. > > The app should work like this: > 1. User starts the round - OK > 2. Hole number is set to 1 - OK > 3. User submits the first hole - OK > 3a. Hole number is saved as 1 - OK > 3b. Hole number increases by 1 - NOT OK > 4. Redirect back to new - OK > Repeat until hole number = 18That''s a *very bad* user interface. The app should not force entry of holes in a particular order. Why not just provide a form for all 18 holes? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser wrote: Why not just provide a form for all 18> holes? >Holy verisimilitude Batman!!! You mean a web page that looks like 99% of the golf score cards in use today? Genius, sheer genius. (no offense intended to anyone, just having fun)... -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ar Chron wrote:> Marnen Laibow-Koser wrote: > Why not just provide a form for all 18 >> holes? >> > > Holy verisimilitude Batman!!! > > You mean a web page that looks like 99% of the golf score cards in use > today? > > Genius, sheer genius.I am always happy to impress. :D> > (no offense intended to anyone, just having fun)...Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>You can store it in a session variable to keep track across requests >session[:hole_number] = hole_numberThanks. I''m sure I''ll find a way to mess that up. Marnen Laibow-Koser wrote:> That''s a *very bad* user interface. The app should not force entry of > holes in a particular order. Why not just provide a form for all 18 > holes?I disagree, you start on the 1st and finish on the 18th so you should enter them in a particular order. Entering my data after I finish each hole is more natural. The best way is probably just to write everything down while I am playing and then put it all in a spreadsheet, but then I wouldn''t learn anything about programming. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sharagoz -- wrote:> You can store it in a session variable to keep track across requests > session[:hole_number] = hole_numberFor the future reference of noobs like myself, this is how I did it. (For Agile Web Development with Rails readers, it''s much easier than their Cart session would have you believe.) def start #start the round session[:hole_number] = 0 redirect_to(new) end def new #modified scaffold @hole = Hole.new session[:hole_number] += 1 ... end def create @modified scaffold @hole = Hole.new(params[:hole]) @hole.hole_number = session[:hole_number] ....other stuff... redirect_to(new) end -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Dan Ci wrote:>>You can store it in a session variable to keep track across requests >>session[:hole_number] = hole_number > > Thanks. I''m sure I''ll find a way to mess that up. > > > Marnen Laibow-Koser wrote: >> That''s a *very bad* user interface. The app should not force entry of >> holes in a particular order. Why not just provide a form for all 18 >> holes? > > I disagree, you start on the 1st and finish on the 18th so you should > enter them in a particular order.Don''t force the user to do that.> Entering my data after I finish each > hole is more natural.For you. And the solution I suggested allows that -- but does not force it.> > The best way is probably just to write everything down while I am > playing and then put it all in a spreadsheet,No. Spreadsheets really aren''t the proper tool for *anything*.> but then I wouldn''t learn > anything about programming.:) Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.