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

  • Home
  • SEARCH
  • 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 7545239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:52:36+00:00 2026-05-30T08:52:36+00:00

So idea is to define def foo puts Works! end and directly from the

  • 0

So idea is to define

def foo
  puts "Works!"
end

and directly from the console without loading anything I write

irb(main):001:0>foo()
=> "Works!"
irb(main):002:0>

I am using 1.9.3 on Windows. I want to use this in order to have a method which will reload lib/* so that I don’t need to restart the console. Thank you.

  • 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-30T08:52:37+00:00Added an answer on May 30, 2026 at 8:52 am

    I think this is what you’re asking… I have the following code in an initializer:

    if defined?(Rails::Console)
      require "util/console_extensions"
      include ConsoleExtensions
    end
    

    and any extra methods I want in the console defined in lib/util/console_extensions.rb

    module ConsoleExtensions
      def foo
        puts "Works!"
      end
    end
    

    This automatically requires and includes the ConsoleExtension module when loading the rails console and makes the methods defined in it available without the need to manually load anything.

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

Sidebar

Related Questions

I am thinking is that a good idea to define exception with template. Defining
I created a UITextField in code, now I have now idea how to define
Any idea how I express 'implements' in UML? I'm trying to write some actionscript
I would like to have a macro which I'll call def-foo. Def-foo will create
When I define a Django form class similar to this: def class MyForm(forms.Form): check
The idea is to walk over multiple dimensions, each one defined as a range
I have a C++ STL set with a custom ordering defined. The idea was
idea Via jQuery, I was able to mark all :first-child and :last-child elements in
idea I would like to create a little app for myself to store ideas
any idea how if the following is possible in PHP as a single line

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.