My model is similar:
class Client < ActiveRecord::Base
VALID_STATES = %w(active suspended closed)
validates :status, :inclusion => { :in => VALID_STATES }
end
Validation works fine if the status is obtained from the form (as a string), but I like to do something like:
@client.status = :active
which throws an error that the status is not in the list, obviously, because it %walso does not generate an array of characters. Is there any work around this, not ending with using strings?
source
share