User and Account models

This has probably been asked a few times before but I can't find a
definite answer to my angle: The app has a User model which only keeps
the account-esque information about the user, e.g. email and password,
and nothing else. The Profile model is used to hold the data we use on a
regular basis, like first name, last name, etc. I've head people saying
that it's good practice to keep these two types of data separated.

Because the regularly accessed user data is stored in the Profile model,
we're often calling @user.profile.some_attribute, and this is making
things a little messy - I'd much rather be calling @user.some_attribute
for data which we seem to be accessing all the time. So, would it be
wise to change things round a bit and to have an Account model for the
account data and use the User model for the data we access all the time?

I'm still new to Rails and web dev in general (haven't deployed a single
Rails app yet), so I don't know if this is a really bad idea; based on
any experiences you have with authenticating users, would this route
work?

You can expose certain attributes in a related record by doing:

class User < ActiveRecord::Base

has_one :profile, :dependent => :destroy

delegate :first_name, :to => :profile

delegate :last_name, :to => :profile

end

It will allow you to access those attributes as @user.first_name, @user.last_name.

Best regards

Peter De Berdt

Peter De Berdt wrote:

http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001055

I’d suggest picking up a book or two on Rails, all the information you need will be in there and it will make the workings of the framework a lot clearer.

Best regards

Peter De Berdt