On Dec 4, 3:05 pm, Rémi Gagnon <[EMAIL PROTECTED]>
wrote:
> I know, I have probably a wrong design.  Just need your point of view on
> that.
>
> Here is
>
> Police has many products
> Police has many transactions
> Products has many transactions
>
> I need to get a transaction with the combination of police and product.
>
> Is it feasible to defines associations to do that.  I know that's weird
> a bit. I think I'm missing a model in between.
>
> Rémi
> --
> Posted viahttp://www.ruby-forum.com/.

I think the design is fine, actually.  If I understand correctly, your
transactions table has columns police_id and product_id (and others).

If so, you can find a transaction this way:

Transaction.find_by_police_and_product(police, product)

This will return the first one that matches.  You can also add further
conditions, ordering, etc. as with any other find.

Jeff

www.purpleworkshops.com

--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to