ruby-on-rails – 添加token_authenticatable以设计迁移

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 添加token_authenticatable以设计迁移前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经使用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

@R_404_323@

从Github的 devise 2.0 generator(第74行):
# t.string :authentication_token

如果您要根据其令牌查找用户,则添加索引是个好主意.

Here is the devise 1.5 file

原文链接:https://www.f2er.com/ruby/273126.html

猜你在找的Ruby相关文章