Skip to content

Instantly share code, notes, and snippets.

@rthbound
Created December 22, 2011 20:52
Show Gist options
  • Save rthbound/1511811 to your computer and use it in GitHub Desktop.
Save rthbound/1511811 to your computer and use it in GitHub Desktop.
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] } }
@dchapman1988
Copy link

Sounds like you might need a new model if you really want to have dynamic statuses

@rthbound
Copy link
Author

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