0

I want to create a rails 4 start up, with devise and omniauth, along with twitter bootstrap and can can.

But my understanding of models isn't so good, hence I am running into a problem with user and identity model.

Identity Model

class Identity < ActiveRecord::Base

  belongs_to :user, :foreign_key => "uid"

...

User Model

class User < ActiveRecord::Base

  include User::AuthDefinitions
  include User::Roles

  has_many :identities

  validates_presence_of :email, :first_name, :last_name

The small github repository is here -: https://github.com/pratik60/tur.

I am sure the problem is because of my lack of understanding of model relations, but I get this error, when I try to sign up -: NameError: uninitialized constant User::Identity basically uninitialized constant User::Identity

Any suggestions?

4

1 回答 1

1

foreign_key 参数应该在用户模型中。

在你的用户模型中试试这个:

has_many :identities, class_name: "Identity", foreign_key: "uid" 

这在您的身份模型中:

belongs_to :user
于 2013-08-19T09:36:07.013 回答