Module: StaticList::Validate::ClassMethods
- Defined in:
- lib/static_list.rb
Instance Method Summary collapse
-
#validates_static_list_value(attribute, model, options = {}) ⇒ Object
Method to validate in the receiving model that the value received is included in the static list model.
Instance Method Details
#validates_static_list_value(attribute, model, options = {}) ⇒ Object
Method to validate in the receiving model that the value received is included in the static list model. For example : with_options(:allow_blank => true) do |options|
.validate_static_list_value :hair_color, HairColor
.validate_static_list_value :ethnicity, Ethnicity
.validate_static_list_value :sex, Sex
end
30 31 32 33 |
# File 'lib/static_list.rb', line 30 def validates_static_list_value(attribute, model, = {}) .merge!(:in => model.static_list_codes.map { |el| el[1] }) validates_inclusion_of attribute, end |