Skip to content

Instantly share code, notes, and snippets.

@tsabat
Last active December 28, 2015 05:59
Show Gist options
  • Save tsabat/7453965 to your computer and use it in GitHub Desktop.
Save tsabat/7453965 to your computer and use it in GitHub Desktop.

we have this file structure:

app/services/payment/code_pen_subscription.rb
app/services/promo/promotion_expire.rb

and the modules/classes defined below.

###promotion_expire.rb

module Promo
  class PromotionExpire

  end
end

###code_pen_subscription.rb

module Payment
  class CodePenSubscription

    def new_suscription_from_promo
       ##stuff
       Promo::PromotionExpire.new.expire_single(@user, true)
       ##/stuff
    end

  end
end

##problem

In production only, we got an exception

NameE​rror:​ unin​itial​ized ​const​ant P​aymen​t::Pr​omo::​Promo​tionE​xpire

To fix, we changed Promo::PromotionExpire to ::Promo::PromotionExpire, which tells ruby to look from root of module hierarchy. But we don't know why

  1. this only happens in production (autoload path?)
  2. why it only happens in this class, not others.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment