I've create a view in MySQL which corresponds to some reports I'm generating (sums grouped by month, year with a roll up). The view has 3 columns (year, month, total). View/Table name is "report_monthly". I know I can use raw sql via connection().select_all(...) but I'd like to create an ActiveRecord for this table.
Here is my model in a file called "report_monthly.rb":
class MonthlyReport < ActiveRecord::Base
# I assume that setting the table name circumvents the pluralized file name convention
set_table_name "report_monthly"
end
The file is placed in the standard rails structure:
app
controllers
helpers
models
report_monthly.rb
views
Now when I use the RoR console (scripts/console) I can't even see the class much less list all of the rows
>> MonthlyReport
NameError: uninitialized constant MonthlyReport
All of my other models work fine, but they follow the convention of "singular.rb" -> class Singluar -> table Plural
UPDATE: Does this have anything to do with the fact that the view is immutable? cannot be inserted/updated?
Versions:
Ruby 1.8.7, Rails 2.3.2, MySQL 5.0.75