I have a file containing a helper class something like this:
app/classes/myfile.rb
Module mymodule
class myclass
# blah blah
end
end
I want to use this class in a controller, so I wrote something like this:
require 'myfile'
class MyController < ApplicationController
include mymodule
def index
mymodule::myclass.new
end
end
The route for the controller is defined like this:
match 'mycontroller', :to => 'mycontroller#index'
Now for the strange behaviour I'm facing. It works perfectly fine on the first run after the server starts. But when I refresh the page or hit the URL again, I get the following error.
Routing Error
uninitialized constant MyController::mymodule
I cannot make out anything out of the error, nor can I understand why it does not work from the second hit onward only. What's happening?