I was able recently to organize my code by grouping everything into folders.
I had an issue with having the same "group name" for both my group of controllers under the app/
directory and my module under the lib/
directory but I was able to fix by following this:
Rails: Same name for a library module and a group of controllers?
I also know that whenever you change your lib
code, you need to restart the rails server which is totally fine by me.
But after the recent re-organization, every time I change the code in the controllers, I get the following error!!!
NameError at /admin
uninitialized constant Admin::PagerDuty
and to resolve it, I simply restart the server!!
Any advice?!
EDIT: STRUCTURE:
Controller main_controller.rb
is under app/controllers/admin
class Admin::MainController < ApplicationController
end
Helper main_helper.rb
is under app/helpers/admin
module Admin::MainHelper
require "admin/pager_duty.rb"
def pager_duty
pagerduty = Admin::PagerDuty.new()
@on_call = pagerduty.on_call()
@counts = pagerduty.open_incidents()
end
end
lib pager_duty.rb
is under lib/admin
module Admin
class PagerDuty
....
end
end