Created
October 25, 2019 21:33
-
-
Save breim/8df085f3349e78017d9373d758dde252 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
# 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