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 7192645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:59:03+00:00 2026-05-28T19:59:03+00:00

I am trying to follow the short example in the following answer on using

  • 0

I am trying to follow the short example in the following answer on using custom functions in rails:

http://stackoverflow.com/questions/2879679/where-to-put-code-snippets-in-rails

In math.rb in lib/math.rb

module Math
    class << self
        def cube_it(num)
          num*3
        end
    end
end

In rails console I have tried

include Math
Math.cube_it(2)

But I get the error:

NoMethodError: undefined method 'cube_it' for Math:module
  • 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-28T19:59:04+00:00Added an answer on May 28, 2026 at 7:59 pm

    check config/application.rb for next line

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

    So if you have still unloadable extension you can type

    require 'math'
    

    and recheck

    instead of call require, you can create config/initializers/lib.rb

    with

    Dir[File.join(Rails.root, “lib”, “*.rb”)].each {|l| require l }

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

Sidebar

Related Questions

I'm trying to follow the basic cometd example here: http://dojotoolkit.org/reference-guide/1.7/dojox/cometd.html It's using the old
So I was trying to follow http://developer.android.com/guide/topics/media/camera.html to create a simple app that captures
I'm trying to follow this tutorial using StructureMap : http://iridescence.no/post/Constructor-Injection-for-ASPNET-MVC-Action-Filters.aspx What I'm trying to
Trying to follow this example. (Section String sorting...) Is there anything obvious that would
Im trying to follow a tutorial that is using SBJsonParser to get twitter feeds,
I'm trying to follow these docs: http://readthedocs.org/docs/neo4j-rest-client/en/latest/indices.html This works fine from neo4jrestclient.client import GraphDatabase,
I'm trying to follow along with Railscasts #235 (Omniauth in a rails app). Having
I have a rather confusing problem. I have a php file (http://example.com/delete.php) <?php session_start();
I have a rather confusing problem. I have a php file (http://example.com/delete.php) <?php session_start();
I'm trying to follow this example to generate an image with dynamic text. I

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.