I have 3 tables, that provide a restful mechanism for creating history
for products. There is a list of (almost static) states that are linked
to a product via a progressions table.
eg states
1 ordered
2 processed
3 sent
PROBLEM
Im interested in getting the release list for a given state, eg
State.find_by_name(''ordered'').products
When i progress a product to processed, that product will still appear
in the ordered list. At the moment i am doing the following, its rather
clumsy:
<pre>
@processed_products = State.find_by_name(''processed'').products
@ordered_products = State.find_by_name(''ordered'').products -
@processed_products
</pre>
This works fine, but now i need to get a count for the tabs (like in
google), and running all those selects seems over kill and SLOW. Ive
been looking at creating a query on the progression object using a
combination of order and distinct, or perhaps an association extension.
But just cant work it out...
TABLES
states
id
name
products
id
name
etc
progressions
id
state_id
product_id
created_by
created_at
--
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 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
-~----------~----~----~----~------~----~------~--~---