实际上,我使用巫术来进行以下设置的认证:
- rails 3.2.3
- postgresql 9.1.3
- cancan
当我点击激活链接时,我就会有以下错误:
ActiveRecord::RecordNotFound in UsersController#activate
Couldn t find User with id=pJycxPPmoBQw9D2mfW6W
<强度 > 用户-控制器.rb 强度 >
# 能够 # can
before_filter :require_login, :except => [:not_authenticated, :new, :create, :activate]
load_and_authorize_resource
skip_authorization_check :only => [:new, :create, :activate]
skip_authorize_resource :only => [:new, :create, :activate]
# 激活方法
def activate
if (@user = User.load_from_activation_token(params[:id]))
@user.activate!
redirect_to(login_path, :notice => Your account is activated. )
else
not_authenticated
end
end
< 强 > generate mass 强 >
def generate_token(column)
begin
self[column] = SecureRandom.urlsafe_base64
end while User.exists?(column => self[column])
end
巫术源代码 < strong > load_ from_activation_token 中的 < streng > 从_activation_token 下装入_activation_token
def load_from_activation_token(token)
token_attr_name = @sorcery_config.activation_token_attribute_name
token_expiration_date_attr = @sorcery_config.activation_token_expires_at_attribute_name
load_from_token(token, token_attr_name, token_expiration_date_attr)
end
能帮个忙吗?