Megan, If you always want this behavior I'd recommend putting it in the model, say, in a before_validation filter.
See this link: http://guides.rubyonrails.org/active_record_callbacks.html Your code would look something like this: before_validation :titleize_wiki_title def titleize_wiki_title title = title.titleize if title.present? end Cheers, Chris On Wednesday, April 30, 2014 9:42:09 AM UTC-7, Megan Byrne wrote: > > Hello all, > > I'm relatively new to RoR and have a quick question. > > I want to make sure that the :title of wikis that are submitted through a > form are always converted to capital letters so that they can be sorted > properly. Currently they are sorted alphabetically, but this becomes a > problem if people do not capitalize their first letter (ie. uppercase > letters sorted first, then lowercase sorted next). > > I know that I want to do something like wiki.title.titleize, which is a > great RoR extension, but where do I put this? Is it something I write into > the create and update methods in the controller? Or, is it something I > write in the model? > > -- -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby --- You received this message because you are subscribed to the Google Groups "SD Ruby" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
