Ruby on rails 为Rails模型中的列指定类名

Ruby on rails 为Rails模型中的列指定类名,ruby-on-rails,ruby-on-rails-4,rails-activerecord,Ruby On Rails,Ruby On Rails 4,Rails Activerecord,我的视图中出现了一个错误,似乎是由于:class\u name=>“user” 我的模型中的子句。有什么想法吗 详细信息 我在Rails中有一个非常简单的自引用模型。这是两个用户之间的友谊 class Friendship < ActiveRecord::Base belongs_to :user belongs_to :friend, :class_name => "user" end 类名应为大写 class Friendship < ActiveRecord::

我的视图中出现了一个错误,似乎是由于
:class\u name=>“user”
我的模型中的子句。有什么想法吗

详细信息

我在Rails中有一个非常简单的自引用模型。这是两个用户之间的友谊

class Friendship < ActiveRecord::Base
  belongs_to :user
  belongs_to :friend, :class_name => "user"
end

类名应为大写

class Friendship < ActiveRecord::Base
  belongs_to :user
  belongs_to :friend, :class_name => "User"
end
类友谊“用户”
结束
class Friendship < ActiveRecord::Base
  belongs_to :user
  belongs_to :friend, :class_name => "User"
end