Skip to content

Instantly share code, notes, and snippets.

namespace :sidekiq do
desc "Clear queued jobs in Sidekiq and reset all stats"
task :reset => :environment do
Sidekiq::Queue.all.each &:clear
Sidekiq::Stats.new.reset
Sidekiq::RetrySet.new.clear
Sidekiq::ScheduledSet.new.clear
end
end
class TenantWebhooksBraintreeController < ApplicationController
protect_from_forgery :except => :process_webhook
skip_before_action :verify_authenticity_token
before_action :verify_event
require 'pp'
def process_webhook
case @event.kind
module TenantServices
class SubscriptionServicePaypal
def initialize(params)
@subscription = params[:subscription]
@coupon = params[:coupon]
@paypal_token = params[:paypal_token]
@plan = @subscription.subscription_plan
@customer = @subscription.customer
@site = @subscription.site
module TenantServices
class CheckoutService
def initialize(params)
@site = params[:site]
@cart = params[:cart]
@customer = params[:customer]
@coupon_code = params[:coupon_code]
@selected_country = params[:selected_country]
class CustomerNotification < ApplicationRecord
belongs_to :site
belongs_to :customer
belongs_to :notifyable, polymorphic: true
acts_as_tenant :site
validates_uniqueness_to_tenant :customer_id, scope: [:notifyable_id, :notifyable_type]
end
class Customer < ApplicationRecord
has_many :following_playlists, class_name:'PlaylistFollower', dependent: :destroy
def follow_playlist!(playlist_id)
following_playlists.create(playlist_id: playlist_id)
end
def unfollow_playlist!(playlist_id)
following_playlists.find_by(playlist_id: playlist_id).destroy
class Playlist < ApplicationRecord
belongs_to :site
belongs_to :customer
belongs_to :user
acts_as_tenant :site
validates_presence_of :title, :content
attr_accessor :spam_answer
class BookmarksController < ApplicationController
BOOKMARKABLES = {
'Course' => Course,
'Lesson' => Lesson,
'Post' => Post,
'LiveStream' => LiveStream,
'Download' => Download,
'Project' => Project,
'Exercise' => Exercise,
module TenantServices
class AccessService
def initialize(params)
@site = params[:site]
@customer = params[:customer]
@user = params[:user]
@record = params[:record]
@feature = params[:feature]
class GiftCard < ApplicationRecord
belongs_to :site
belongs_to :subscription_plan, optional: true
acts_as_tenant :site
include ProductConcern
include ImageUploader[:image]
enum status: { draft:0, published:1}