Skip to content

Instantly share code, notes, and snippets.

@jurikern
Created August 23, 2012 08:36
Show Gist options
  • Save jurikern/3434316 to your computer and use it in GitHub Desktop.
Save jurikern/3434316 to your computer and use it in GitHub Desktop.
Dropdown list validation on rails > 3.2
class Person
validates :gender_id, :presence => true, :inclusion => { :in => proc { |req| req.gender_types.map{ |key, value| key } } } #req - self 'Person' object
validates :title_id, :presence => true, :inclusion => { :in => proc { |req| req.title_types.map{ |key, value| key } } }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment