我应该为 oauth 令牌使用什么 rails 字段类型?

What rails field type i should use for a aouth token?

我不知道我应该在迁移文件中使用什么类型来获取我从雅虎获得的 outh 令牌,我应该使用 :text 类型的列还是有一个特殊的列?

class AddColumnsToUsers < ActiveRecord::Migration
  def change
    add_column :users, :provider, :string
    add_column :users, :uid, :string
    add_column :users, :first_name, :string
    add_column :users, :last_name, :string
    # the tokens
    add_column :users, :oauth_token, :string
    add_column :users, :oauth_token_secret, :string
  end
end

OAuth Token 的大小似乎没有上限。

如果以Facebook为例,就是documentation states:

Please use a variable length data type without a specific maximum size to store access tokens.

This Quora feed 您可能也会感兴趣。

另请参阅 Doorkeeper gem source code 的评论:

If you use a custom token generator you may need to change this column from string to text, so that it accepts tokens larger than 255 characters.

所以我的建议是使用 TEXT 字段,而不是 STRING。