Hi all, I am creating a bash.org-like. Basically: just store and retrieve quotes that people enter. I would like the user to have the option of entering a few fields, among which are a date a and location field. What do you think is the best default to use for these fields? nil, or today''s date (or January 1st, year 1), or an empty string? It may be possible later to search or sort using these fields, which is why I am asking how you would do this. I may have not searched well, but I didn''t find anything on the web about this. Thanks :) -- 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.
On May 10, 2010, at 9:14 AM, Aldric Giacomoni wrote:> Hi all, > I am creating a bash.org-like. Basically: just store and retrieve quotes > that people enter. I would like the user to have the option of entering > a few fields, among which are a date a and location field. > What do you think is the best default to use for these fields? nil, or > today''s date (or January 1st, year 1), or an empty string? > It may be possible later to search or sort using these fields, which is > why I am asking how you would do this. I may have not searched well, but > I didn''t find anything on the web about this.If it were me... I''d default the date to today, and leave location blank. Defaulting the date to today makes some sense as 6 months from now if I''m searching I''ll remember "well, i entered it about 6 months ago so search around then". That doesn''t work with location so leave it blank. -- 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.
Aldric Giacomoni wrote:> Hi all, > I am creating a bash.org-like. Basically: just store and retrieve quotes > that people enter. I would like the user to have the option of entering > a few fields, among which are a date a and location field. > What do you think is the best default to use for these fields? nil, or > today''s date (or January 1st, year 1), or an empty string?Depends on your use case. If you think that most of the time, the user will want to date things today, then use that as a default. 1/1/1 is probably not a sensible default in most cases, and an empty string certainly wouldn''t be sensible for a date field (which shouldn''t contain a string). In most cases, then, for date, I''d probably use either nil or a reasonable date (such as today). For location...can you use Google''s currentLocation or some such to get the client''s location if possible? That would be a great default for many applications. If not, nil is good here too.> It may be possible later to search or sort using these fields, which is > why I am asking how you would do this. I may have not searched well, but > I didn''t find anything on the web about this. > > Thanks :)Note that this is really a general UI and database design question. You will probably come up with the best solutions if you think in those directions. 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:> > Depends on your use case. If you think that most of the time, the user > will want to date things today, then use that as a default. > > For location...can you use Google''s currentLocation or some such to get > the client''s location if possible? That would be a great default for > many applications. If not, nil is good here too.Phillip, Marnen, Thanks. Those suggestions make a lot of sense :) -- 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.
Philip Hallstrom wrote:> > If it were me... I''d default the date to today, and leave location > blank. Defaulting the date to today makes some sense as 6 months from > now if I''m searching I''ll remember "well, i entered it about 6 months > ago so search around then". >So.. How should I tell Rails that "This field''s default date is always today" ? Can I do this within the migration, or should I set the field upon form generation? -- 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.
Aldric Giacomoni wrote:> Philip Hallstrom wrote: >> >> If it were me... I''d default the date to today, and leave location >> blank. Defaulting the date to today makes some sense as 6 months from >> now if I''m searching I''ll remember "well, i entered it about 6 months >> ago so search around then". >> > > So.. How should I tell Rails that "This field''s default date is always > today" ? Can I do this within the migration, or should I set the field > upon form generation?Well, if it were a constant default value, I would say that you should set it in the DB, not in Rails. Since "today" is a computed default value, check whether your DB will do this. If it will, you''re home free. If not...well, you''re using form_for, right? That means you always have an object that your form is reading from, right? That means you can initialize defaults in the constructor. -- 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.
Aldric Giacomoni wrote:> Philip Hallstrom wrote: >> >> If it were me... I''d default the date to today, and leave location >> blank. Defaulting the date to today makes some sense as 6 months from >> now if I''m searching I''ll remember "well, i entered it about 6 months >> ago so search around then". >> > > So.. How should I tell Rails that "This field''s default date is always > today" ? Can I do this within the migration, or should I set the field > upon form generation?Well, if it were a constant default value, I would say that you should set it in the DB, not in Rails. Since "today" is a computed default value, check whether your DB will do this. If it will, you''re home free. If not...well, you''re using form_for, right? That means you always have an object that your form is reading from, right? That means you can initialize defaults in the constructor. 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:> > If not...well, you''re using form_for, right? That means you always have > an object that your form is reading from, right? That means you can > initialize defaults in the constructor. >Duh. That''s the clean way to do it, of course. Thank you, Marnen :) -- 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.