title: Ruby gem, undefined method `ruby gem name' for Model (call 'Model.connection' to establish a connection):Class)
body: <p>I'm creating a ruby gem with rails 6. This is my main ruby gem file:</p>
  <pre><code>#lib/ruby_gem_name.rb
  
  require 'active_support'
  require 'active_record'
  require 'ruby_gem_name/version'
  require 'ruby_gem_name/class_methods'
  
  # frozen_string_literal: true
  
  puts 'The gem was loaded'
  
  module RubyGemName; end
  </code></pre>
  <p>This is <code>lib/ruby_gem_name/class_methods.rb</code></p>
  <pre><code>module RubyGemName
    module ClassMethods
      def self.ruby_gem_name_class_method
        puts 'Hello'
      end
    end
    extend ClassMethods
  end
  
  </code></pre>
  <p>i enter in irb console and i can see:</p>
  <pre><code>ruby-gem-name$ irb
  2.7.1 :001 &gt; require 'ruby-gem-name'
  The gem was loaded
   =&gt; true 
  2.7.1 :002 &gt; RubyGemName::ClassMethods.ruby_gem_name_class_method
  Hello
   =&gt; nil
  </code></pre>
  <p>Now....I've added my gem to the gemfile in my rails project:</p>
  <pre><code>gem 'ruby_gem_name', path: 'path_to_ruby_gem_name'
  </code></pre>
  <p>I can see the installed gem in Gemfile.lock:</p>
  <pre><code>PATH
    remote: 'path_to_ruby_gem_name'
    specs:
      ruby_gem_name (0.1.0)
        activerecord (~&gt; 6)
        activesupport (~&gt; 6)
        rails (~&gt; 6)
  
  GEM
    remote: https://rubygems.org/
    specs:
      actioncable (6.0.3.5)
        actionpack (= 6.0.3.5)
  
  </code></pre>
  <p>Now, i want to use this class method in models of my rails project:
  i have this code:</p>
  <pre><code>class Cart &lt; ApplicationRecord
    extend RubyGemName::ClassMethods
  end
  </code></pre>
  <p>and when i try to use this class method from my rails project console, i see:</p>
  <pre><code>shopping-cart$ bundle exec rails c
  Running via Spring preloader in process 32494
  Loading development environment (Rails 6.0.3.5)
  2.7.1 :001 &gt; Cart.ruby_gem_name_class_method
  Traceback (most recent call last):
          1: from (irb):1
  NoMethodError (undefined method `ruby_gem_name_class_method' for Cart (call 'Cart.connection' to establish a connection):Class)
  </code></pre>