Request advice on best/usable field default

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 :slight_smile:

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.

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 :slight_smile:

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 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 :slight_smile:

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?

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.

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 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 :slight_smile: