Rails Development for iPhone with rails_iui

iphone_sim.jpg

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://github.com/noelrappin/rails-iui.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.

Related Services: iPhone Application Development, Ruby on Rails Development, Custom Software Development

Related posts:

  1. “Developing iPhone applications using Ruby on Rails and Eclipse, Part 2: Displaying iPhone content to the client” Also up on IBM Developerworks
  2. TankEngine: New plugin for Rails iPhone Development
  3. Rails and iPhone article online at IBM developerWorks
  4. “Developing iPhone applications using Ruby on Rails and Eclipse, Part 3: Developing advanced views for iPhone” now available on IBM Developerworks
  5. acts_without_database: Now a Rails Plugin

Comments: 11 so far

  1. This looks awesome! Thanks for putting it together :)

    One problem though: When I run the iui:install rake task, I get this error:

    gzip: stdin: unexpected end of file
    tar: Unexpected EOF in archive
    tar: Unexpected EOF in archive
    tar: Error is not recoverable: exiting now

    All of the files looks like they down load properly, but it doesn’t move them to the ‘public’ folder and re-link the CSS. Any advice? I used Git to clone the rails-iui directory into my vendor/plugins dir in my Rails app. Should it go somewhere else?

    Thanks :)

    Comment by Eric, Tuesday, May 6, 2008 @ 2:00 pm

  2. I get an error like this (which I think might be a problem in how I’m managing the gzip), but I do get all the files moved to the public folder.

    Try this: download the file to vendor, if the tar didn’t work, manually untar it, which should create the directory vendor/iui.

    Then the following two rake tasks will do the other parts of the install

    rake iui:copy

    rake iui:change_root

    Noel

    Comment by Noel Rappin, Tuesday, May 6, 2008 @ 2:13 pm

  3. The extra rake tasks did the trick, Noel. Thanks a million :)

    Comment by Eric, Wednesday, May 7, 2008 @ 7:52 am

  4. This definitely looks interesting!

    I made a small change to the rake tasks so that only the iui directory is extracted (as opposed to the whole archive including examples) into the vendor directory. I also delete the tar.gz after extraction.

    These changes are available at my clone of your repo on github:
    http://github.com/ciaranlee/rails-iui/tree/master

    I can’t figure out how to stop the tar error from happening though, but it’s working fine for me anyway…

    Ciaran

    Comment by Ciaran Lee, Wednesday, May 7, 2008 @ 9:15 am

  5. Ciaran — Great, could you submit that as a pull request on github?

    Comment by Noel Rappin, Wednesday, May 7, 2008 @ 9:46 am

  6. hey could any one help me out in the detail install of iui plugin for rails.I am trying it big time but not able to .

    thanks

    Comment by sparrow, Wednesday, July 30, 2008 @ 8:02 am

  7. hey problem solved !!!!

    Comment by sparrow, Wednesday, July 30, 2008 @ 8:35 am

  8. [...] I know, I’ve done this already, so why a brand-new version of the plugin with a new [...]

    Pingback by Pathfinder Development » TankEngine: New plugin for Rails iPhone Development, Friday, September 26, 2008 @ 1:24 pm

  9. I can’t find any good documentation or examples anywhere. Can anybody shed some light on how to use the iui_list function, specifically how to create the Items it requires? Thanks!

    Comment by P.J., Wednesday, April 8, 2009 @ 6:20 pm

  10. well, here it is, so you finally scrolled down to the comments and just cant get it to install from the git in windows,

    download the plugin manually from the git page, place the contents in the plugins directory in a rails-iui directory.

    download the iui from http://code.google.com/p/iui/downloads/list and unzip it into the vendor directory , so it should have an iui directory and samples directory and some other files.

    now do

    rake iui:copy

    rake iui:change_root

    rake iui:install

    and what these do is copy the css and js file from the iui directory in to the rails eqivalent directories of images and javascript, and renames the extensions in the css file according to the rails root directory.

    thats it! you are all set, no more googling!

    Comment by krishna, Saturday, November 21, 2009 @ 12:16 pm

  11. [...] his website: Get the plugin from github: git://github.com/noelrappin/rails-iui.gitRight now the plugin is [...]

    Pingback by Rails Development for iPhone with rails_iui | Android Developers :: iPhone App Development, Monday, January 25, 2010 @ 4:53 pm

Leave a comment

Powered by WP Hashcash

Launch: Pathfinder Newsletter

    Get a monthly update on best practices for delivering successful software.

    Subscribe via email


    Subscribe via RSS      RSS icon

Topics

Search

WordPress

Comments about this site: info@pathf.com