Posted tagged ‘Rails plugins’

Fixing iphone4r

March 12, 2008

There’s a very nice looking plugin for Rails to make it easier to develop iPhone versions of web sites and applications, called iphone4r. It is the work Nicholas Schlueter of Simpltry.com, and built on top of work done by (no surprise!) Joe Hewitt.

The only problem I’ve had with it so far is that it doesn’t work! Okay, the problem is quite small, and fairly easily fixed if you have even the slightest understanding of Rails plugins. Since the plugin fails to copy the iui directory to your /public directory, just add a line to install.rb to copy that over. When you’re done, install.rb should look like this:

require 'fileutils'
RAILS_ROOT = File.dirname(__FILE__) + "/../../../" unless defined? RAILS_ROOT
# Install hook code here
def copy_files(source_path, destination_path, directory)
  source, destination = File.join(directory, source_path), File.join(RAILS_ROOT, destination_path)
  FileUtils.mkdir(destination) unless File.exist?(destination)
  FileUtils.cp(Dir.glob(source+'/*'), destination)
end
directory = File.join(File.dirname(__FILE__), "copy_on_install")
copy_files("/script", "/script", directory)
FileUtils.chmod 0755, File.join(RAILS_ROOT, "script", "ibug"), :verbose => true
copy_files("/public/ibug", "/public/ibug", directory)
copy_files("/public/iui", "/public/iui", directory)