我目前正在开发一个ActiveStorage
已安装的 Rails 6 应用程序。我正在使用设计进行身份验证。尝试在注册表单上创建新用户时出现以下错误。
ActiveSupport::MessageVerifier::InvalidSignature in RegistrationsController#create
我认为原因来自试图为模型设置默认头像User
。创建用户时,我尝试将其设置astronaut.svg
为默认头像。
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_many :posts
has_one_attached :avatar
before_create :set_defaults
def set_defaults
self.avatar = 'assets/images/astronaut.svg' if self.new_record?
end
end
怎么修?