Upgraded ShoutSMS from Rails 2.3.8 to Rails 3 in five minutes

Today I wanted to try how easy it would be to upgrade our existing ShoutSMS (pretty small) rails application from 2.3.8 to latest Rails 3 release candidate (currently rc3). Without taking our test suite into consideration it took around five minutes with help from the official rails_upgrade[1] plugin. This is fast, yes, but considering the size of this app and possible pitfalls I am not looking forward to upgrade our larger projects.

These are the basic steps to perform

  • Install rails_upgrade in my 2.3.8 project using “./script/plugin install http://github.com/rails/rails_upgrade”
  • Run rake tasks installed with plugin to check what steps are required with “rake rails:upgrade:check”
  • Run “rake rails:upgrade:backup” to backup some files which will be override shortly
  • Run “rake rails:upgrade:configuration >> upgrade_configuration”
  • Run “rake rails:upgrade:gems >> upgrade_gems”
  • Run “rake rails:upgrade:routes >> upgrade_routes”
  • Create new Rails 3 app above your existing one with “rails n .”
  • Check each of your files before overriding – not all are backed up with the backup task
  • Copy back in your changes and refer to the three “upgrade_*” files for updated configuration, gems and routes syntax

This did most of the work for me. I needed to patch a bit in my new “application.rb” file (e.g. replace RAILS_ROOT with Rails.root, RAILS_ENV with Rails.env, etc).

Notice, the rails_upgrade plugin might suggest to change “<% @object.each do |p| %>” blocks to “<%= @object.each do |p| %>” but I don’t see this should be done.

I needed to upgrade ActiveMerchant but it was a simple

$ gem update activemerchant

and then patch my Gemfile with correct version

gem 'activemerchant', '1.7.1', :require => 'active_merchant'

It was also needed to go through each ERb and update block helpers. Rake task “rake rails:upgrade:check” can be used multiple times to check if you’re near the end.

I had a couple of “f.error_messages” warnings as well. It’s suggested to install “rails plugin install git://github.com/rails/dynamic_form.git” but I made a partial instead to have complete control over my displayed error messages.

For more general upgrade tips & tricks you might consider viewing part 1, part 2 and part 3 of the “Upgrading to Rails 3” Railscasts series.

How to send mass text messages from your own number

A couple of months ago we needed to make a service which would be able to send out sms text messages to a large number of people. The text message itself should come from a specific number so recipients would be able to reply back for more information.

Another requirement was the ability to send a text message to a specific number and then trigger the mass sending to the configured recipients.

The part sending out bulk sms is easy. A lot of companies have great, simple APIs to do this but they do not allow for incoming sms without paying a considerable up-front amount (easily $2k). We would like to avoid paying this and thought of solutions and found one using Twitter. Basically it should be possible to send a tweet (via SMS, which is possible) and have this tweet delivered to all your configured recipients.

We built ShoutSMS for this purpose but have currently disabled the Twitter integration since it was based on Basic Authentication which is going to be discontinued today. Instead we need to update our code to use OAuth and we plan to update this shortly.

The ShoutSMS service is very simple but very cheap as well. You sign up, confirm your number and import your list of phone numbers. Then you’re ready to go. Since we temporarily disabled the Twitter integration it’s possible to send messages directly from the site as well. Since we confirmed your number we are able to send out messages on your behalf so all messages will come from your confirmed phone number.

How ShoutSMS work - developer graphic :)

If this sounds interesting and maybe something your company could use for mass marketing, you should head over to the ShoutSMS web site and create an account. You will get a couple of free sms to check out the features.

Send your weight from an iPhone through SMS

While working on lifestyleapps I have been asked a couple of times, if it would be possible to report your weight by sending an SMS from your phone. This is already possible and I have been using it from my iPhone 3G for a long time.

The trick is to associate your Twitter account to your lifestyleapps account and set up your Twitter to accept SMS. In order to report your weight you need to follow @reporting which is the lifestyleapps Twitter account and by following this (and it will follow you back) it’s possible to send a direct message to avoid everyone having to see your weight.

This is the screen to associate your Twitter account in lifestyleapps

Associating your Twitter account in lifestyleapps

In order to send your weight you simply enter

d reporting weight 82.4

This will report your weight as “82.4” kg and insert it for todays date. You might shorten the message to

d reporting w 82.4

Lifestyleapps will check messages sent to @reporting each minute and see if an associated lifestyleapps account exists for that Twitter handle. If that’s the case, the weight entry is inserted into your lifestyleapps account.

If you are on an iPhone you might be interested in Twpie which is an upcoming application allowing you to send similar tweets fast. It does this by storing recently sent tweets and order these by usage count and last updated date.

Tracking coffee intake with touchatag and Lifestyleapps

I have bought a touchatag RFID reader and a couple of touchatag RFID tags and was wondering how I could use these to track my daily intake in lifestyleapps.

Underneath

I noticed a Twitter application already has been developed which post a message from a configured account. Since lifestyleapps already integrate with Twitter it was a simple matter of associating a direct message and prefixing it with “h” or “having” to let lifestyleapps know you are reporting an intake.

Many cups of coffee are consumed on a daily basis by me and I thought I would make tracking this easier for myself by configuring a touchatag with a Twitter message of “d reporting having Coffee, instant, prepared with water”. This means “d” for direct message, “reporting” for the Twitter user receiving our message (used by lifestyleapps), “having” to tell lifestyleapps you are reporting an intake and “Coffee, instant, prepared with water” to make lifestyleapps look up this specific intake and figuring out its nutrition values.

Ontouchatag Website

Now whenever I drink a cup of coffee I just need to place my coffee mug on a touchatag reader and it will automatically trigger a Twitter message which will be read by lifestyleapps. And this can by done using no code at all.

This is a pretty sweet thing and I’m planning to put a couple of tags on my breakfast food items since I almost eat the same breakfast every morning. It would be nice to be able to just put a bottle of milk, a bag of bread and a jar of jam on my reader to track my breakfast within lifestyleapps.

If you don’t know about lifestyleapps you are welcome to sign up for a free account at http://lifestyleapps.com. Read more about touchatag at http://www.touchatag.com.