Tuesday, October 31, 2006

Collecting email addesses on your website

In email marketing it is important to use the names of your subscribers to establish connection. When users fillout the forms to subscribe to your list some of them will be lazy and enter names in all lowercase. When you merge the fields during mailing your newsletter it can be very tedious to clean up the database.

In Rails, you can cleanup the name fields as follows:

test = "StRrIPPed TEst"
test.upcase.titlecase

This will create a string : "Strripped Test"

Remember that Rails has opened the existing string class and added these methods to it. So to find out the methods that are available:

~/work/testr > ./script/console
(From the Rails project directory)

> test.methods

will give you list of all available methods.

No comments:

Post a Comment