Hello RoR World-
i’ve defined a number of string arrays in /lib/valid.rb which i’m
using to validate input for various fields, e.g.
TITLES = [ ‘Mr.’, ‘Mrs.’, ‘Ms.’, ‘Dr.’, ‘Sir’, ‘RoRN00b’, ‘PhD.’,
In my models I’ve done the following, which is working great for my
:in => TITLES,
:message => ‘%s is Invalid - please enter a valid Title.’
Now I’d like to simplify my user’s lives by utilizing these same
constants as the basis of my collection_selects in my assorted
<%= form.collection_select( :title, TITLES.all, TITLES, TITLES )%>
My two questions:
I’m receiving the error:
uninitialized constant ActionView::Base::CompiledTemplates::TITLES
despite having my obligatory ‘include VALID’ statement in my client.rb
model; tried adding to controller, no joy.
I’m sure my collection_select syntax above is broken; if/when i
get past the unintialized constant error i’m sure I can sort it
relatively quickly (i hope), but if anyone’s done this before and
cares to share their code-fu I’d appreciate it.