Im creating an expense report.
I don't know if Im on the right path but heres what im thinking...
When submitting an expense report the user could have travel expenses,
parking expenses, cell phone expenses or even meal expenses.
Each expense available shares 3 common attributes
-cost, occurrence, GL code
(some expenses will need additional attributes).
My first thought was to use STI:
class User < ActiveRecord::Base
end
class Expense < ActiveRecord::Base
(which have the cost, occurrence, GL code attributes)
end
class Travel < Expense
end
class Entertainment < Expense
(and this class and some others will be needing additional attributes)
end
/////////////////
1. A user selects a month and year this expense will belong to
2. A user then selects which 'type' of expense they're going to fill out
(i.e. Travel expense)
3. User submits that form
4 Repeat as needed
I want to be able to:
view all expenses for a user
view all user expenses associated with a month/year
View all user expenses via a 'type' of expense
I wanted to use STI but not all models will be all the same as some will
have additional attributes so then I thought okay maybe polymorphism
will be needed. Any help would be gratifying thank you!
--
Posted via
http://www.ruby-forum.com/.