I followed the excellent post from Frank Rietta about "Adding a Rake Task for SQL Views to a Rails Project". I like his point of view about database views in rails and his dry approach.
I am able to do
rake db:views
models/reports/revenue.rb
class Report::Revenue < ApplicationRecord
self.table_name = 'report_revenues'
end
rails console --sandbox
Report::Revenue
2.3.1 :004 > Report::Revenue
NameError: uninitialized constant Report
I think Rails expects the module name and the folder name to match. Note that you mixed singular and plural.
That said you have to change your model to:
class Reports::Revenue < ApplicationRecord
self.table_name = 'report_revenues'
end
Or move your model into a folder named models/report/revenue.rb
.