Selects and validates_presence_of

I have an array of attributes that I use for select menus, and thus
validations on those fields when theyre updated.

in my view i have something like:

<% select ‘thing’, ‘stuff’, Thing.stuff_options, :allow_blank => true %>

and in my validations

validates_inclusion_of :stuff, :in => STUFF, :allow_nil => true

The problem being that blank != nil so the validation fails if the user
picks the ‘blank’ select option.

Sorry the subject should read validates_inclusion_of.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs