Question

I have a number of methods that I would like to make available to the entire application. Based on what I read and researched, I did the following:

1. Created a lib/app_lib.rb

and defined some methods in it.

2. In config/application.rb, I added the following lines:

    config.assets.enabled = true
    config.autoload_paths += %W(#{config.root}/lib)

This however is not working, as when I try to call one of the methods in any of the controllers or views, I get the error message:

undefined local variable or method ....

This is for Rails 4.1

Was it helpful?

Solution

in case lib/app_lib.rb is a module, you need to include it into your application controller!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top