Had this working until I refactored by putting into a hash and checking
for blank. Now I get the error: undefined method `key?' for
nil:NilClass.
I'm still kind of new at this and would appreciate suggestions on what I
am missing...
before_validation :capitalize_first_words
def capitalize_first_words
[:question, :correct_ans_1, :correct_ans_2, :correct_ans_3].each
do |key|
self.key = self.key.gsub(/^(\W*?[a-z])/) { |m| m.upcase } if
self.key != blank
end
end
Thanks,
Dave
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/1abbb33bff62ddb8abba0998a602b469%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.