Skip to content

Instantly share code, notes, and snippets.

@breim
Created October 25, 2019 21:33
Show Gist options
  • Save breim/8df085f3349e78017d9373d758dde252 to your computer and use it in GitHub Desktop.
Save breim/8df085f3349e78017d9373d758dde252 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
class Influencer < ApplicationRecord
include ProviderHelper
belongs_to :user
has_many :influencer_analytics
validates_uniqueness_of :provider, scope: :provider_code
store :data, accessors: %i[instagram youtube], coder: JSON
scope :active_influencers, -> { where( authorized: true, active: true).order(created_at: :desc) }
scope :active_influencers_of_user, ->(current_user) { active_influencers.where(user_id: current_user) }
def profile_picture_url
super || '/influencer-default.jpg'
end
def profile_completion
attributes.values.select(&:nil?).count
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment