Nov 20
I just posted a small update (version 0.2) to acts_as_formatted. It fixes a few bugs and adds ‘capitalize_words’. Obviously, it’s a recommended update!
Edit: 0.3 is already out! I added the possibility to call acts_as_formatted more than once on the same model, which is very useful! The project page is at http://rubyforge.org/projects/actsasformatted/. The lastest README is at http://rubyforge.org/viewvc/README?root=actsasformatted&view=markup.
Nov 05
I was doing a little Ruby on Rails hacking and I needed an easy way to automatically format ActiveRecord string columns. I was surprised that this wasn’t built into Rails already, and even more when I couldn’t find a 3rd party plugin that did that. I guess the open source community was calling on me to write my own!
I’m glad to introduce acts_as_formatted 0.1. Here’s an example of how it works. As you can see, it is pretty straightforward:
class Person < ActiveRecord::Base
acts_as_formatted :case => :capitalize, :except => :suffix
end
This snippet formats all string fields by Capitalizing the first letter of a string, and by stripping leading and trailing white spaces. No more custom setters. acts_as_formatted can also change the case to UPPERCASE, lowercase or sWAP cASE. Check out the README for more details on usage and installation instructions. Comments are welcome, of course!
Recent Comments