Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems referencing code in bundled gems

Status
Not open for further replies.

c73mr0ck

Programmer
Oct 25, 2012
11
0
0
US
Hello,
I'm working on my first gem and I'm having a problem referencing dependencies. In my gem, I need to reference code from some other custom gems we've developed.
We'll call my Gem "test_company_models". In my test_company_models gem, I need to include PricingExtensions from our test_company_libs Gem.

I'm dynamically requiring my models in my test_company_models.rb this way:

Code:
Dir[File.join(File.dirname(__FILE__), '/test_company_models/*.rb')].each do |file|
  # skip previously loaded files to avoid duplicate warnings
  next if File.basename(file, File.extname(file)) == 'version'
  require File.join( File.dirname(__FILE__), "vst_models/#{File.basename(file, File.extname(file))}")
end

This works fine until I am pulling in a model which references PricingExtensions from the test_company_libs Gem:

Code:
class CartItem < ActiveRecord::Base
  include PricingExtensions

Which gives me this error:

Code:
uninitialized constant CartItem::PricingExtensions

I've tried adding the test_company_libs Gem to my Gem in these two ways:


Gemfile:
Code:
gem 'test_company_libs', :git => 'git@github.com:test_company/test_company-libs.git', :require => false

and in the test_company_models.gemspec:

Code:
spec.add_runtime_dependency "test_company_libs"
In either case, I get the "uninitialized constant CartItem::pricingExtensions" error.


Any idea as to what I am doing wrong?

Thanks,
Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top