Why do you have it? Don't worry, people with obsessive-compulsive disorder can't afford to hurt themselves! It's a little bit of a trifle. Feel itchy: is if the table payment_types often change what to do? Do you want to shut down the Rails Web server and restart it every time? That's too much trouble Bird, the final solution is that In order validation, it is mandatory to pull the payment type data from the table in the database each time, and the last modified ORDER.RB code is as follows:
Class Order < ActiveRecord::Base has_many:line_items,dependent::d estroy validates_each:p ay_type do | model,attr,val| Unless PaymentType.types.include? (Val) Model.errors.add (attr, ' Payment type not on the list ') end EndEnd
After a toss, stupid cat seems to understand a little: first to find out the real reason behind the problem is what, otherwise is nonsense; second, in the uncertainty when the pace is small, slow, do not expect a success, or the consequences are very painful, you know ...
Rails will refactor the class constants into the database corresponding to the table after the