rails validate in model that value is inside array
ActiveModel::Validations
provides a helper method for this. An example call would be:
validates_inclusion_of :type, in: @allowed_types
ActiveRecord::Base is already a ActiveModel::Validations, so there is no need to include anything.
http://apidock.com/rails/ActiveModel/Validations/HelperMethods/validates_inclusion_of
Also, @RadBrad is correct that you should not use type
as a column name as it is reserved for STI.
first, change the attribute from type to something else, type is a reserved attrubute name use for Single Table Inheritance and such.
class Thing < ActiveRecord::Base
validates :mytype, :inclusion=> { :in => @allowed_types }