1

I use rails 4.1. I created a module in lib/ folder in Rails: lib/corelib.rb but when I try to use it in my custom initializer file config/initializers/load_data.rb with

include Corelib

it gives me an error:

.../config/initializers/load_data.rb:1:in `<top (required)>': uninitialized constant Corelib (NameError)

How do I use my module from lib/ folder in my initializer?

1 Answer 1

3

Apparently I've forgotten to add require before include:

require 'corelib'
include Corelib

on top of the file in load_data.rb fixes the issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.