On 1 August 2011 22:20, OES <[email protected]> wrote: > 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.
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 > > 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!! > > -- > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

