I have a module in /lib
Module Info
class Inf
def getNum
num = Array.new
num.push(2,1)
end
end
In the controller informations_controller I have ‘require Info’ and the follow code:
def index
@informations = Info::Inf.getNum().num
respond_to do |format|
format.html # index.html.erb
format.json { render json: @informations }
end
end
But it always gives the error
Routing Error
uninitialized constant Info
Since the router I have defined “root :to => ‘informations#index'” what could be missing?
it should be
modulenot Module and also you should name fileinfo.rband also you should be sure lib is in auto_load paths inconfig/application.rbso it should be something like this
lib/info.rb: