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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:13:22+00:00 2026-06-13T23:13:22+00:00

This is an evolving issue related to a previous posting I made… I am

  • 0

This is an evolving issue related to a previous posting I made…

I am playing around some – to try to learn how the /lib/ directory in Rails works – and how to reference variables defined in the /lib/ directory for use in a view.

I have a file called helloworld.rb and it’s saved in a /lib/hellotest/ directory in Rails.

The helloworld.rb file has the following code:

module HelloWorld
  def hello
    @howdy = "Hello World!"
  end
end

I want to be able to display the results of this method on a view called index.html.erb, so I include the following code in the index_helper.erb file:

module IndexHelper
  require 'helloworld'
end

I have learned that I need to include the following line of code in the /config/application.rb file:

config.autoload_paths += %W(#{Rails.root}/lib/hellotest/)

Also, I include the following code on the view index.html.erb:

<%= @howdy %>

I think I may have found something that is causing problems. I didn’t want to load the entire /lib/ directory at startup so I put the file in a subdirectory called /lib/hellotest/. I’ve read there are some issues with how Rails interprets module/class naming conventions in the lib folder, but I can’t quite figure it out. I see a good resource regarding this possible solution to my problem on William B Harding’s Blog, on point 2 – but I can’t quite get my arms around this solution as it pertains to my problem.

Any advice please?

What am I missing?

  • 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-06-13T23:13:22+00:00Added an answer on June 13, 2026 at 11:13 pm

    I’d suggest that unless you have a good reason to do otherwise, follow the conventional naming for modules and classes (as described in the link you provided). Rename helloworld.rb to hello_world.rb, move it into lib, and change your autoload_paths to:

     config.autoload_paths += %W(#{Rails.root}/lib/)
    

    Finally, change require 'hello_world' to require 'hello_world' in your IndexHelper module. It should then load normally.

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

Sidebar

Related Questions

I have this mysql query (evolving two tables : Users and Files ) that's
This question is related to hooking with Mobile Substrate, but as long as you
This is a super simple issue that I can't figure out. I want to
I've just seen this really nice talk Rock Hard: C++ Evolving by Boris Jabes.
this question had been evolving in my mind, how do i totally stop the
This is a pretty simple question, and I searched the previous questions but couldn't
Slickgrid is continuosly evolving so some of the answers to similar issues are not
First of all Around this world there are lots of people that lawfully and
I've been previously managing a 3-module project as 3 seperate maven projects. As this
I've been asking a series of evolving questions regarding my Android project that continually

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.