Add and inherit from ApplicationRecord to match Rails 5.0 style
This commit is contained in:
parent
8c6d48da86
commit
abe847c0ee
34 changed files with 56 additions and 66 deletions
|
|
@ -1,7 +1,7 @@
|
|||
require 'digest/sha1'
|
||||
|
||||
# Invites are created by foodcoop users to invite a new user into the foodcoop and their order group.
|
||||
class Invite < ActiveRecord::Base
|
||||
class Invite < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :group
|
||||
|
||||
|
|
@ -13,9 +13,9 @@ class Invite < ActiveRecord::Base
|
|||
validate :email_not_already_registered, :on => :create
|
||||
|
||||
before_validation :set_token_and_expires_at
|
||||
|
||||
|
||||
protected
|
||||
|
||||
|
||||
# Before validation, set token and expires_at.
|
||||
def set_token_and_expires_at
|
||||
self.token = Digest::SHA1.hexdigest(Time.now.to_s + rand(100).to_s)
|
||||
|
|
@ -32,4 +32,3 @@ class Invite < ActiveRecord::Base
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue