i’ve got a specific problem here and I’m not sure how to handle it.
what i need to do is sort a has_many association in a very specific way.
class Foo < AR::Base
class Thing < AR::Base
class Order < Thing
class BInCheck < Thing
class Problem < Thing
class Special < Thing
class CycleCount < Thing
class Notification < AR::Base
PRIORITIES = [:order, :bin_check, :problem, :special, :cycle_count]
now, what i need to do when when a foo goes into an ‘available’ state,
i need to create a notification for whatever needs foo next, based on
the notification priorities. the problem is the sorting. what i want
to do is sort the things for foo according to the
Notification::PRIORITIES array. so that all i have to do is pass the
first element in to generate the notification. note, that date also
plays a part in that if there are 2+ of any type, they are sorted by
date (:created_on attribute).
one thing i thought of using was an association extension on Foo
has_many :things do
bug again, i’m still blocked on the sorting.