SwitchUp SwitchUp Ranked Best Coding Bootcamps 2025

Rails model restrict values from an array of string

Altcademy Team wrote on 7 February 2018

You can use
class ClassName < ApplicationRecord validates :column_name, inclusion: { in: %w(restrict_text_1, restrict_text_2, restrict_text_3) } end

Trusted by

Students and instructors from world-class organizations

Join the upcoming Cohort #111

Enroll for March 2nd, 2026