Reputation: 15207
I have a class in the lib directory:
lib/static.rb
Inside that I have:
class Static
def self.boo
return 'what'
end
end
I have a controller:
class PensionsController < ApplicationController
layout 'page'
def guides
render :text => Static.boo
end
end
And i'm getting this error:
undefined method `boo' for Static:Class
Any ideas what i'm doing wrong here?
Upvotes: 0
Views: 200
Reputation: 814
Are you using Rails 2 or 3? In Rails 3 classes in the lib directory aren't loaded by default.
I have this line at the bottom of config/application.rb to enable that behavior:
config.autoload_paths += %W(#{config.root}/lib)
Upvotes: 1