2
在railscast#274瑞恩在用户模式下面的代码:Railscast 274:self [column]?
def generate_token(column)
begin
self[column] = SecureRandom.urlsafe_base64
end while User.exists?(column => self[column])
end
什么是自[专栏]是指什么?
因此,它是同一事物或几乎相同事情?如果是这样,有什么区别? – mikeglaz 2014-10-03 16:03:03
答案中包含差异的示例。 – 2014-10-03 16:07:13
@MichaelGlaz [这是源代码](https://github.com/rails/rails/blob/28c1a81f9a06c8bc268881771ffc1b678cf944a4/activerecord/lib/active_record/attribute_methods.rb#L380)如果你想看到更多。 – 2014-10-03 16:29:19