I am trying to create several models that all pull from the same table. How do I limit the table records in each model? And before you tell me to change my data structure, this is a reporting application that is pulling from a preexisting backing DB over which I have no control.
My table looks something like:
Vehicle_Table
id vehicle_type name
--------------------
1 Car Foo
2 Car Bar
3 Motorcycle Baz
4 Car Barf
And I want to build models for Car and Motorcycle like:
class Car < ActiveRecord::Base
set_table_name 'Vehicle_Table'
end
and
class Motorcycle < ActiveRecord::Base
set_table_name 'Vehicle_Table'
end
But I have no idea how to say, "Hey Active Record, I only want records where vehicle_type = motorcycle in the motorcycle model."
I'm sure this is friggin' obvious, but all of my Google searches return ways to FIND subsets in a model rather than RESTRICT a model to a specific subset of records.