Skip to content

Instantly share code, notes, and snippets.

@mayra-cabrera
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayra-cabrera/8837451 to your computer and use it in GitHub Desktop.
Save mayra-cabrera/8837451 to your computer and use it in GitHub Desktop.
# Trial URL
class TrialUrl < ActiveRecord::Base
scope :for_sales_rep, ->(sales_rep_id) { where(sales_rep_id: sales_rep_id) }
belongs_to :sales_rep, class_name: "OleCore::Login", foreign_key: "sales_rep_id"
end
# Login
module OleCore
Login.class_eval do
def url
trial_url = ::TrialUrl.for_sales_rep(self.id).first
return unless trial_url
trial_url.url
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment