其实我用巫术进行认证与以下设置:
找不到用户使用id = pJycxPPmoBQw9D2mfW6W
- 轨3.2.3
- 的PostgreSQL 9.1.3
- 康康舞
当我点击激活链接我得到以下错误的:
ActiveRecord::RecordNotFound in UsersController#activate
Couldn't find User with id=pJycxPPmoBQw9D2mfW6W
users_controllers.rb
#cancan
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]
#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
生成令牌
def generate_token(column)
begin
self[column] = SecureRandom.urlsafe_base64
end while User.exists?(column => self[column])
end
个load_from_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
我能有一些帮助吗?
显然,你在'#activate'中有错误。但是由于我们没有看到它的代码,我们无法帮助你。 –
刚刚添加#activate方法 – blawzoo
也添加其他相关方法。 –