class User < ActiveRecord::Base
...
def generate_token(column)
begin
self[column] = SecureRandom.urlsafe_base64
end while User.exists?(column => self[column])
end
...
end
3 行目のコードがself[column]
有効なのはなぜですか? self
はclassのインスタンスなのでUser
、columnではなくself.columnにすべきではないでしょうか?var[index]
それが配列処理のやり方だと思いましたね。