我试图将模型的不同部分移入关注点。其中两个是 AASM 定义的状态,以及 Paperclip 的附件。
所以,我将相关代码移动到单独的文件中。
应用程序/模型/关注/user_aasm.rb
class User
module UserAasm
extend ActiveSupport::Concern
included do
include AASM
aasm do
state :unverified, initial: true
state :approved
state :suspended
state :deleted
state :banned
end
end
end
end
在我的 user.rb 中,我做
include UserAasm
我收到以下错误:
Unable to autoload constant UserAasm, expected app/models/concerns/user_aasm.rb to define it
我想知道我在代码中出了什么问题。如何以正确的方式使用它?