Friday, May 23, 2008

Notes and Notes

A couple of recent life, the universe, and everything notes:

  • I realize I've been away from here for most of the last couple of weeks -- a side project has been eating up a lot of time. I should be done with in next week, and back to posting here more regularly. I know, I always say that.

  • I'll be at RailsConf 08 later this month, and I'll probably have some number of copies of Professional Ruby on Rails to do something promotional with, but I haven't exactly decided what. If you are going, I hope to see you there.

  • The rails_iui plugin was mentioned on the Rails Envy Podcast -- thanks to Gregg for the mention. There are now just over 35 people following the project on GitHub. I do plan to add more features over the coming weeks.

  • On a related note, I've turned in a 3-part article for IBM DeveloperWorks about iPhone development with Ruby on Rails. No idea when it'll show up, though.

Monday, May 05, 2008

Rails Development for iPhone with rails_iui


I've been doing some web development for iPhone and Mobile Safari lately, not least because of a series of articles that will be showing up in IBM DeveloperWorks soon.

I was using the iUI toolkit, which contains a number of CSS styles and JavaScript event handlers to make iPhone Web apps look and feel somewhat like native iPhone applications. As I was working with iUI, I realized I was building up a library, so I converted everything to a Rails plugin: rails_iui.

Get the plugin from github: git://

Right now the plugin is primarily interested in doing a few things:

It contains a rake task to download iUI, move it's files to the Rails public directories, and change the CSS image URL's accordingly.

There's a controller class method acts_as_iphone_controller, calling that sets up a before filter that captures the Mobile Safari user agent string and sets the request format to iphone for use in respond_to blocks. For testing purposes you can call the method as acts_as_iphone_controller(true), and all calls will be treated as iPhone requests.

There is a module of helper methods that are wrapper methods or combinations of iUI CSS classes. Included are:

  • A method for creating the iPhone toolbar at the top of the view.

  • Methods for creating the iPhone list structures from a list of elements that know their associated URLs, including a grouped list in the style of the iPod application

  • Rounded rectangle classes

  • A form helper for the iPhone toggle button, as seen in the settings page.

  • A method to specify an Ajax callback when the phone changes orientation

The short term goals for the project are to tighten the code a bit and improve documentation and testing. Longer term goals are to augment iUI's JavaScript handlers with something a bit friendlier with Rails, particularly in handling history and back behavior.

So take it for a spin, let me know what you think. Hope you find it useful.

Please check out my book, Professional Ruby on Rails.