Skip to content

Instantly share code, notes, and snippets.

@pmatsinopoulos
Created April 12, 2025 09:02
Show Gist options
  • Save pmatsinopoulos/7a0df745fde6fe8b2b367faaadbd26a5 to your computer and use it in GitHub Desktop.
Save pmatsinopoulos/7a0df745fde6fe8b2b367faaadbd26a5 to your computer and use it in GitHub Desktop.
User model for Thread-and-Process-safe Sidekiq Job
class User < ApplicationRecord
has_one :user_balance, dependent: :destroy
validates :email, presence: true, uniqueness: { case_sensitive: false }
after_create :create_user_balance
private
def create_user_balance
create_user_balance!(balance: 0.0)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment