Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6971295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:49:17+00:00 2026-05-27T16:49:17+00:00

I am trying to add a module to my Rails 3.1 app, I’ve been

  • 0

I am trying to add a module to my Rails 3.1 app, I’ve been able to do this before, but it is not working now with the latest module I’ve added. Any thoughts greatly appreciated

in application.rb

    # Custom directories with classes and modules you want to be autoloadable.
    config.autoload_paths += %W(#{Rails.root}/app/workers 
                                #{Rails.root}/lib/validators
                                #{Rails.root}/lib/content_items
                                #{Rails.root}/lib/booher_modules
                              )

in lib/booher_modules/mongoid_counter_cache.rb

module Mongoid
  module CounterCache
    extend ActiveSupport::Concern

    module ClassMethods
      def counter_cache(options)
        ... some stuff ... 

Now vote.rb:

class Vote
  include Mongoid::Document
  include Mongoid::Timestamps
  include Mongoid::CounterCache

Anytime I try to boot up the application, I get the uninitialized constant error:

Users/Tim/Sites/polco/app/models/vote.rb:4:in `': uninitialized constant Mongoid::CounterCache (NameError)
    from /Users/Tim/Sites/polco/app/models/vote.rb:1:in `'
    from /Users/Tim/.rvm/gems/ruby-1.9.2-p290@cba/bundler/gems/mongoid-ccae125ccfd8/lib/rails/mongoid.rb:66:in `load_model'
        ... so on

I tried to put require ‘lib/mongoid_counter_cache.rb’ in vote.rb, but I get:

rails c
/Users/Tim/.rvm/gems/ruby-1.9.2-p290@cba/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:306:in `rescue in depend_on': No such file to load -- lib/mongoid_counter_cache (LoadError)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:49:18+00:00Added an answer on May 27, 2026 at 4:49 pm

    You’re having this issue because Rails is trying to include “Mongoid::CounterCache”.

    To do this, it is looking for the file “mongoid/counter_cache.rb” somewhere in the autoload path.

    So…

    ...
    lib/booher_modules/mongoid/counter_cache.rb
    ...
    

    Thus to fix…

    mkdir -p lib/booher_modules/mongoid
    mv lib/booher_modules/mongoid_counter_cache.rb lib/booher_modules/mongoid/counter_cache.rb
    

    The reason your specific “require ‘lib/mongoid_counter_cache.rb'” doesn’t work is because that doesn’t look in the autoload path it looks in the main include path ($:) which doesn’t include lib/booher_modules (only autoload is configured with that)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to add a blank sample app for a rails tutorial to GitHub, but
I'm trying to add activeadmin to my rails 3.0.3 app. I'm following the instructions
I'm working on a module and am trying to add some javascript to the
I'm trying to create a Rails app template I have this block of code
I am trying to add this module . I have added the zip file
Im new to asp.net mvc. I'm trying add new model class but it got
Trying to add email notification to my app in the cleanest way possible. When
Trying to add a class object into a List using reflection, but when invoking
I am trying to port an existing rails app running rails 2.3.8 to 3.0.0beta4.
I'm trying to add Forum module to my Web Site , so I add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.