I recently upgraded my application from rails 6 to 7 and I am facing one issue due to zeitwerk naming convention. I have a below file which I want to autoload:
app/models/dw/hospital.rb
module DW
class Hospital < DataWarehouse
def self.columns
super.reject{|column| column.name == 'tableau_user' }
end
end
end
I tried autoloading this file by adding the following line in my application.rb
file:
config.autoload_once_paths << 'app/models/dw'
But when I am starting the server I am getting the following error:
expected file app/models/dw/hospital.rb to define constant Hospital, but didn't (Zeitwerk::NameError)
I'm not sure why this is throwing such error since the constant is already defined. I suspect it is because the module I have defined before the class. Please let me know if anybody how to fix this. I have been stuck at this far too long.