rails/rails — pull request #18217 by robertomiranda (2014-12-27 03:26:50+00:00)
Title: Add has_secure_token to Active Model

I take the audacity of include has_scure_token to Active Model since the implementation is using methods that are implemented in most of popular ORMs or ODMs in ruby, like `exists?`and `save`, is just as suggestion and for sure I'm open to move it to Active Record anyway :smile:. Is still missing documentation but I'd like to hear first opinions about the implementation/code

**Usage**

```ruby
class User < ActiveRecord::Base
has_secure_token :token1, :token2, key_length: 30
end

user = User.new
user.save
user.token1 # => "973acd04bc627d6a0e31200b74e2236"
user.token2 # => "e2426a93718d1817a43abbaa8508223"
user.regenerate_token1! # => true
user.regenerate_token2! # => true
```

ref #16879

cc @dhh