UserEngine + User Profiles

I’m taking a new approach to how I view user data, I think in the end it
will be faster for the system anyways… What I’m doing is using
LoginEngine/UserEngine combo on my site for authorization, and I want
each user to have a profile that they edit and maintain. Each user
would have 1 profile.

My question is getting my profile and my user account to have a
relationship. I have in my Profile model:

class Profile < ActiveRecord::Base
has_one :user
end

In my user.rb - I’m editing the user_engines/app/,odel/user.rb directly
for now:

class User < ActiveRecord::Base
include LoginEngine::AuthenticatedUser
include UserEngine::AuthorizedUser

belongs_to :profile

In my profiles database I have a user_id field that is of type int(11).
What I was expecting to happen (and this is obviously me being a newbie)
is that when I enter in a new profile the user_id field would
automagically be filled in by the relationship. Can anyone give me a
hand getting this going?

On 28 Apr 2006, at 21:20, Ray Slakinski wrote:

class User < ActiveRecord::Base
include LoginEngine::AuthenticatedUser
include UserEngine::AuthorizedUser

belongs_to :profile

A user doesn’t belong to a profile. A profile belongs to a user.

class User < ActiveRecord::Base
has_one :profile
end

class Profile < ActiveRecord::Base
belongs_to :user
end

And then things will act as you expect.


Paul R.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs