【发布时间】:2019-07-18 23:59:35
【问题描述】:
我目前正在开发一个安装了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
如何解决?
【问题讨论】:
标签: ruby devise rails-activestorage ruby-on-rails-6