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/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/49a7d926ea0564896ab20d1ff65f79c2%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to