Last active
July 28, 2016 03:57
-
-
Save GiancarlosIO/4ecb7674260ed0910b05f1ac323311df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# my_api/app/models/user.rb | |
class User < ActiveRecord::Base | |
validates :email, presence: true, uniqueness: true | |
validates :name, presence: true | |
def self.with_token(data) | |
User.where(email: data[:email]).first_or_create do |user| | |
user.email = data[:email] | |
user.name = data[:name] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment