我正在尝试在 Solidus 框架之上构建一个朋友功能,但在与 Spree::Users 建立多对多关系时遇到了麻烦。我尝试制作一个 user_decorator.rb 文件(在模型/狂欢中),但一直遇到错误:“预期 user_decorator.rb 来定义 Spree::UserDecorator,但没有”。
用户装饰器:
Spree::User.class_eval do
has_many :friendships
has_many :friends, through: :friendships
end
友谊模型:
class Friendship < ActiveRecord::Base
belongs_to :spree_user, :class_name => 'Spree::User'
belongs_to :friend, :class_name => 'Spree::User'
end
错误: