ruby-on-rails – 添加token_authenticatable以设计迁移
发布时间:2020-12-16 20:19:07 所属栏目:百科 来源:网络整理
导读:我已经使用devise创建了一个用户模型,但是现在我想添加对token_authenticable的支持,所以我需要迁移这些添加.以下是正确的,什么类型应该是token_authenticatable? class AddAuthenticationTokenToUser ActiveRecord::Migration def change add_column :user
我已经使用devise创建了一个用户模型,但是现在我想添加对token_authenticable的支持,所以我需要迁移这些添加.以下是正确的,什么类型应该是token_authenticatable?
class AddAuthenticationTokenToUser < ActiveRecord::Migration def change add_column :users,:token_authenticatable add_index :users,:authentication_token,:unique => true end end 解决方法
从Github的
devise 2.0 generator(第74行):
# t.string :authentication_token 如果您要根据其令牌查找用户,则添加索引是个好主意. Here is the devise 1.5 file (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |