Skip to content

Instantly share code, notes, and snippets.

@pmaojo
Created November 24, 2016 01:19
Show Gist options
  • Save pmaojo/976359825384fce78f710d581b9f605d to your computer and use it in GitHub Desktop.
Save pmaojo/976359825384fce78f710d581b9f605d to your computer and use it in GitHub Desktop.
class User < ApplicationRecord
before_create :check_user_exists
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
private
def check_user_exists
user = User.first_or_initialize(:email => email)
if !user.new_record?
if puntos >= user.puntos
user.puntos = puntos
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment