Ruby on Rails Monday, August 31, 2015

On 31 August 2015 at 19:12, John Lahr <johnelahr@gmail.com> wrote:
> I would look into the concept of a single table inheritance for a
> transactions table...you'd have to add an extra attribute/column that would
> be 'transaction' type to indicate whether it's an expense or income, but
> this should be able to be done with a simple 1 to many relationship - a user
> has many transactions - Single Table Inheritance is great for things like
> this and Rails handles it very easily.

Whether the added complication of STI is worth the benefits in this
case depends on what code differences there are between income and
expenses. I would start off with the simple solution and if it
becomes apparent that STI would be beneficial then refactor it at that
point.

Colin

>
> On Monday, August 31, 2015 at 7:47:26 AM UTC-7, Pradeep Achuthan wrote:
>>
>> Hi,
>>
>> I am building an expense tracker application and I am in middle of data
>> modelling. I have a Users table. Each user will log his expenses with
>> expense type and income with income type. So I need to know how can we set
>> up associations for it.
>>
>> I have User, Expense, Income and UserTransaction models.
>>
>> Expense and Income will have following fields
>>
>> id, date, category, amount, description, user_id, currency
>>
>> I am not sure whether I need UserTransaction table also.
>> But my business requirement is as follows
>>
>> I should be able to get all expenses/income of a user with date range and
>> also with category
>>
>> I should also be able to get all transactions occurred with date range.
>
> --
> 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 rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/b17f15cb-fbe5-47c8-be72-c369ba8ae0d6%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv4OJVRzrwjBvPKkzkBmkqvuODUAcmdF0UJmWCLLHcK7A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment