Created
December 22, 2011 20:52
-
-
Save rthbound/1511811 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STATUSES = Order.all.collect{|x| x.status}.uniq | |
# Currently : STATUSES = ["SHIPPED", "PROCESSING", "RECEIVED", "INCOMPLETE", "VOIDED", "REFUNDED", "FRAUDULENT", "ON HOLD"] | |
validates_inclusion_of :status, :in => STATUSES | |
STATUSES.map{|x| x.downcase.gsub(" ", "_")}.each_with_index { |s,index| named_scope s, :conditions => { :status => STATUSES[index] } } |
No one needs dynamic statuses. Just avoiding hard coding values. Josh's fork is better. The lambda bit.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sounds like you might need a new model if you really want to have dynamic statuses