Add has_secure_token to Active Record

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 
You’re right, Josef. Good catch!

> On Dec 28, 2014, at 12:38 PM, Josef Šimánek <notifications@github.com> wrote:
> 
> In activerecord/lib/active_record/secure_token.rb <https://github.com/rails/rails/pull/18217#discussion-diff-22300209>:
> 
> > +      #
> > +      #   user = User.new
> > +      #   user.save
> > +      #   user.token # => "44539a6a59835a4ee9d7b112"
> > +      #   user.regenerate_token # => true
> > +      def has_secure_token(attribute = :token)
> > +        # Load securerandom only when has_secure_key is used.
> > +        require 'securerandom'
> > +        define_method("regenerate_#{attribute}") { update! attribute => self.class.generate_unique_secure_token(attribute) }
> > +        before_create { self.send("#{attribute}=", self.class.generate_unique_secure_token(attribute)) }
> > +      end
> > +
> > +      def generate_unique_secure_token(attribute)
> > +        10.times do |i|
> > +          SecureRandom.hex(12).tap do |token|
> > +            if exists?(attribute => token) && i == 9
> Actually this is not good also. i == 9 should be around raise statement. Now it will raise only if last iteration will produce existing token, but only one iteration will be done, since first token will be returned, because this statement will be false.
> 
> This is also reason for that failing test.
> 
> —
> Reply to this email directly or view it on GitHub <https://github.com/rails/rails/pull/18217/files#r22300209>.
>