When I first call an action in my in my Orders controller I get the following:
uninitialized constant Order::PAYMENT_TYPES and on refresh I get undefined method 'key?' for nil:NilClass.
This points to an error in my models code. I’m able to track it down to the following lines:
validates :pay_type, inclusion: PAYMENT_TYPES
PAYMENT_TYPES = [ "Check", "Credit Card", "Purchase Order"]
What am I doing wrong with my validates line?
I’ve also tried using validates :pay_type, inclusion: {in: PAYMENT_TYPES} as well and that didn’t work.
It’s because you are defining your PAYMENT_TYPES constant after you are using it in your class. Reverse the order and it should be fine.