Assuming that you want STI:
create_table :financial_transactions do |t|
t.string :transaction_type
...
end
class FinancialTransaction < AR:Base
self.inheritance_column :transaction_type
...
end
class Income < FinancialTransaction
...
end
class Spending < FinancialTransaction
...
end
On Mar 6, 6:19 am, miv
<michael.varamashv...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> For fun, I wanted to write a wallet application. There must be
> tranasctions with came in to flavors - income and spendings. After
> playing for a while, i wanted to make everything pretty.
>
> I have something like:
>
> class FinancialTransction < AR::Base
> belongs_to :transactinable, :polymorphic => true
> end
>
> class Income < AR::Base
> end
>
> class Spending < AR::Base
> end
>
> Then i though - why should i have almost empty models just for the
> sake of saving id. I tried this and that, but nothing works. It''s
> either empty transactionable_type or two separate records (first
> without type, second with).
>
> My question: how to implement this? is there some beautiful way?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---