Newbie Model Question

Hey Folks, Sorry for this newbie question but I am interested on how
you would do the following.

Lets say I have a User model and a User has_one Profile

On the Profile I would like to store basic data ie Gender, Date of
Birth etc… Then I get to data like yearly income or marital status.

In the past I may have used ENUM’s for marital status but would have
used yearly income as a integer for a related table ie, income_id
and then created a Income model to hold possible changing values.

With rails not supporting ENUM’s (from what I can work out with
migrations) I was wondering do most of you have allot of related
tables for this sort of thing?

There will be allot of lookups on the user profile so I’m looking for
the best approach.

Hope you can advise!!

Hi!

See if this article can help you:

http://gregmoreno.ca/preventing-model-explosion-via-rails-serialization/

Best Regards,

Everaldo

P.S: I’m a newbie too, so I can’t find the “better words” to describe
the
solution. =)

On 1 August 2011 22:20, OES [email protected] wrote:

and then created a Income model to hold possible changing values.
For income, where you have a separate table, you want user belongs_to
income and income has_many users. See the Rails Guide on Associations
to see what this does for you. If you have not already done so then
look (in depth) at the other guides also.

I shall be interested on input from others on the best way to handle
the marital status.

I strongly recommend working right through a good tutorial such as the
railstutorial.org (free to use online). Make sure that the guide
matches the version of rails you have (which should probably be
version 3.0). It may appear that the tutorial has little relevance to
your application but you will learn a huge amount about the principles
of Rails even if the sample app itself is not relevant to your needs.

Colin

On 1 August 2011 22:20, OES [email protected] wrote:

On the Profile I would like to store basic data ie Gender

Sex. Gender is a term about language being masculine/feminine/neutral.
Sex is male/female.

On 2 August 2011 07:31, Colin L. [email protected] wrote:

Then I get to data like yearly income or marital status.

I shall be interested on input from others on the best way to handle
the marital status.

This is a good analysis of modelling martial status in DB’s (with all
the complication it can cause):

On 2 Aug 2011, at 08:32, Michael P. [email protected] wrote:

On 1 August 2011 22:20, OES [email protected] wrote:

On the Profile I would like to store basic data ie Gender

Sex. Gender is a term about language being masculine/feminine/neutral.
Sex is male/female.

Except that you’re not really interested in finding out whether the user
has dangly bits or not (their physical sex); you’re interested in
finding out their social gender identity is, and ‘gender’ has been an
accepted term for that concept for decades now.

On gender and forms:

http://meloukhia.net/2009/12/beyond_the_binary_forms.html

Chris

On 2 August 2011 09:02, Chris M. [email protected] wrote:

On 2 Aug 2011, at 08:32, Michael P. [email protected] wrote:

On 1 August 2011 22:20, OES [email protected] wrote:

On the Profile I would like to store basic data ie Gender

Sex. Gender is a term about language being masculine/feminine/neutral.
Sex is male/female.

Except that you’re not really interested in finding out whether the user has
dangly bits or not (their physical sex); you’re interested in finding out their
social gender identity is

sigh So how many forms have an option for “gender neutral”, or some
other option?

I assert that the existance of the dangly bits (or otherwise) is
exactly what the question is trying to determine - mostly the
institutions that are asking this question are trying to put the
answerer into a binary box, they’re not really interested in what
“gender identity” someone has.

‘gender’ has been an accepted term for that concept for decades now.

accepted != correct

I recall that in my childhood, it was very accepted to make racist and
sexist jokes on prime-time telly… it doesn’t mean that it was a
good, correct or tasteful thing to do. Fortunately, those minority of
people who thought it not appropriate managed to sway the general
opinion.

On gender and forms:
http://meloukhia.net/2009/12/beyond_the_binary_forms.html

yep… if people want to blur their “identity” based on their feelings
about their identity; more power to them. I’m all for their freedom.
As far as I can see, asking for a confirmation of “gender indentity”
is like asking for a sexual preference, and has no place in any census
(other than, maybe, dating site registration forms). Get rid of the
sex boxes all together I say, and make a person’s sex irrelevant in
their day-to-day dealings. But while the world wants to know the
orientation of your danglies, the label for the question is “sex” :slight_smile: