Thanks goes to Ryan52 for his explanation of this on the #slicehost irc.
multiverse is non free not officially supported.
restricted is non free officially supported.
main is free officiaully supported.
universe is non free officially supported.
This information was particularly helpful. I was missing multiverse at the end of my sources list at /etc/apt/sources.list
It looked like this:
deb http://archive.ubuntu.com/ubuntu/ hardy main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy main restricted universe
deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe
deb http://security.ubuntu.com/ubuntu hardy-security main restricted universe
deb-src http://security.ubuntu.com/ubuntu hardy-security main restricted universe
and now it looks like this thanks to Ryan52s knowledge
deb http://archive.ubuntu.com/ubuntu/ hardy main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu hardy-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu hardy-security main restricted universe multiverse
Then I just ran sudo aptitude update to update my sources list.
I recently had to do this to get download some lib files using apt-get. In particular: http://packages.ubuntu.com/hardy/libdevel/libx264-dev when trying to follow Jim Neath’s tutorial on installing FFMPEG
No Comments | November 11, 2008
The go to from railscasts but a little out of date since Rails 2.1 implemented timezones
Fixed to work with SQLite and Rails 2.1
Using jquery
No Comments | October 27, 2008

Install jrails and jrails_in_place_editing
script/plugin install git://github.com/aaronchi/jrails.git
script/plugin install git://github.com/rakuto/jrails_in_place_editing.git
Setup jrails in application.html.erb
1
2
3
| <head>
<%= javascript_include_tag :defaults %>
</head> |
Restart your server
Setup jrails_in_place_editing in the..
1. ..Controller
1
2
3
4
| class ProjectsController < ApplicationController
in_place_edit_for :project, :acreage
...
end |
2. ..View
1
| <%= in_place_editor_field :project, :acreage %> |
That’s it. For more on customization and additional options check out the jrails_in_place_editing readme at:
No Comments | October 11, 2008
Get the latest iui
svn checkout http://iui.googlecode.com/svn/trunk
Inside there is the iui folder. Copy that folder to the public directory of your merb app.
Setup application.iphone.erb
This loads the javascript and css files as well as setting up the toolbar.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Title</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<meta name="apple-touch-fullscreen" content="YES" />
<link rel="stylesheet" href="/iui/iui.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="/stylesheets/iui-custom.css" type="text/css" media="screen" charset="utf-8" />
<script type="application/x-javascript" src="/iui/iui.js"></script>
</head>
<body>
<div class="toolbar">
<h1 id="pageTitle"></h1>
<a id="backButton" class="button" href="#"></a>
<a class="button" href="#searchForm"></a>
</div>
<%= catch_content :for_layout %>
</body>
</html> |
Add redirect option to iui.js form submit
1
2
3
4
5
6
7
8
9
10
11
12
13
| // original
function submitForm(form)
{
iui.showPageByHref(form.action || "POST", encodeForm(form), form.method);
}
// added from http://cookingandcoding.wordpress.com/2008/09/05/iphone-web-applications-with-iui-and-ruby-on-rails-part-1/
function submitForm(form)
{
if (form.getAttribute("redirect") == "true")
form.submit();
else
iui.showPageByHref(form.action || "POST", encodeForm(form), form.method);
} |
Setup your views
All your views should be named with the iphone extension. e.g. show.iphone.erb or show.iphone.haml, etc.
Most importantly, the iui javascript and css makes some opinions about how you should format your javascript in order to easily retain that ‘iphone look and feel’.
The pdf book “iPhone in Action” is the best resource for this that I could find (check it out at http://www.manning.com/callen/), but you can read through this tutorial on iUI and Rails for the basics of that look and feel.
Add the iphone mime type
(I stole the following from this great tutorial on providing different formats in merb by hassox. Thanks hassox!)
In init.rb put:
1
2
3
4
| Merb::BootLoader.after_app_loads do
# iPhone mime-type
Merb.add_mime_type(:iphone, :to_html, %w[application/xhtml+xml])
end |
In controllers/application.rb put:
1
2
3
4
5
6
7
8
9
| class Application < Merb::Controller
before :set_iphone_content_type
private
def set_iphone_content_type
self.content_type = :html if self.content_type == :iphone
self.content_type = :iphone if request.user_agent =~ /(Mobile\/.+Safari)/
end
end |
That’s it. Reset your local server, and you should now be able to navigate to http://localhost:4000 in iphoney and see your cool new iphone optimized site.
No Comments | October 1, 2008
Use render for actions like create and new, where you don’t really want to share the xml or even want xml created. Or json for that matter.
Use display to render actions like index and show, where you do want to share the information via xml.
render means you want to render a template — or a string. display means you want to render a resource. so display will do what it can return something to the client
it checks for a template and if that’s missing calls #to_ on the model
# courtesy unagi-san
Here’s the render method on merb-core head and display method on merb-core head
No Comments | September 24, 2008
sudo gem uninstall --a --ignore-dependencies .+
Thank you loopkid
Also here’s how to uninstall a particular long list of gems. I find this particularly useful for merb which has tons of gems.
1
| sudo gem uninstall --a --ignore-dependencies merb.+ |
No Comments | September 23, 2008
1. Install Git on ALL computers (local, remote git, and remote web server)
A. For installation on a mac or windows computer, google the web.
B. For remote git server and remote web server (assumes you’re on ubuntu hardy or something similar)
mkdir ~/sources
cd ~/sources
wget http://kernel.org/pub/software/scm/git/git-1.6.0.tar.bz2
sudo apt-get build-dep git-core
tar xjf git-1.6.0.tar.bz2
cd git-1.6.0/
./configure
make
sudo make install
2. SSH into your git server and setup the remote repository
mkdir ~/git
cd ~/git
mkdir example.git
cd exmplae.git
git init
3. On your local computer create your local repository for your app
mkdir example
cd example
git init
touch README
git add README
git commit -m 'Initial import'
git remote add origin git@REMOTE_SERVER:git/example.git
git push origin master
4. Now you can deploy app with capistrano from your local machine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
| #example deploy.rb
set :runner, "username"
set :use_sudo, false
# =============================================================================
# CUSTOM OPTIONS
# =============================================================================
set :user, "username"
set :application, "example"
set :domain, "domain.com"
role :app, domain, :cron => true
role :web, domain
role :db, domain, :primary => true
# =============================================================================
# DATABASE OPTIONS
# =============================================================================
set :rails_env, "production"
# =============================================================================
# DEPLOY TO
# =============================================================================
set :deploy_to, "/home/#{user}/apps/#{application}"
# =============================================================================
# REPOSITORY
# =============================================================================
set :repository, "ssh://username@REMOTE_SERVER:3444/home/username/git/#{application}.git" # If using a NON-STANDARD PORT instead of default 22. For git server.
set :scm, "git"
set :branch, "master"
# =============================================================================
# SSH OPTIONS
# =============================================================================
default_run_options[:pty] = true
ssh_options[:paranoid] = false
ssh_options[:keys] = %w(/Users/username/.ssh/id_rsa)
ssh_options[:port] = 3333 # If using a NON-STANDARD PORT instead of default 22. For deployment server.
# =============================================================================
# RAKE TASKS & OTHER SERVER TASKS
# =============================================================================
namespace :cron do
task :start, :roles => :app, :only => {:cron => true} do
cron_tab = "#{shared_path}/cron.tab"
run "mkdir -p #{shared_path}/log/cron"
require 'erb'
template = File.read("config/cron.erb")
file = ERB.new(template).result(binding)
put file, cron_tab, :mode => 0644
# merge with the current crontab
# fails with an empty crontab, which is acceptable
run "crontab -l >> #{cron_tab}" rescue nil
# install the new crontab
run "crontab #{cron_tab}"
end
end
namespace :cron do
task :stop, :roles => :app, :only => {:cron => true} do
cron_tmp = "#{shared_path}/cron.old"
cron_tab = "#{shared_path}/cron.tab"
begin
# dump the current cron entries
run "crontab -l > #{cron_tmp}"
# remove any lines that contain the application name
run "awk '{if ($0 !~ /#{application}/) print $0}' " +
"#{cron_tmp} > #{cron_tab}"
# replace the cron entries
run "crontab #{cron_tab}"
rescue
# fails with an empty crontab, which is acceptable
end
# clean up
run "rm -rf #{cron_tmp}"
end
end
desc 'Fix images from disappearing'
task :fix_images, :roles => :app do
%w{images}.each do |share|
run "rm -rf #{release_path}/public/#{share}"
run "mkdir -p #{shared_path}/system/#{share}"
run "ln -nfs #{shared_path}/system/#{share} #{release_path}/public/#{share}"
end
end
desc "Create symlink to public_html/#{domain}/public"
task :symlinkify do
run "rm -rf /home/#{user}/public_html/#{domain}/public; ln -s #{current_path}/public /home/#{user}/public_html/#{domain}"
end
desc "Reload Apache"
task :reload_apache do
sudo "/etc/init.d/apache2 reload"
end
# Edit this accordingly.
after "deploy", "deploy:migrations"
after "deploy:migrations", "deploy:cleanup"
after "deploy:cleanup", "fix_images"
after "fix_images", "symlinkify"
after "symlinkify", "reload_apache" |
Resources:
No Comments | September 19, 2008
First install dependencies you’ll probably need
sudo gem install erubis rake json_pure rspec rack hpricot mime-types ruby2ruby ParseTree memcache-client templater haml mailfactory sequel mongrel libxml-ruby english addressable builder
Install thor
We will use thor to track Merb from git HEAD - which just means that we will keep up with the latest development version.
mkdir ~/sources
cd ~/sources
git clone git://github.com/wycats/thor.git
cd thor
rake install
Install merb.thor file
I like to keep my code projects in their prospective framework/language folder. (i.e. in ~/documents/code/rails are my rails apps and in ~/documents/code/merb are my merb apps). I am going to put the merb.thor file in this merb folder.
cd ~/documents/code/merb/sources
curl -L http://merbivore.com/merb.thor > merb.thor
Use merb.thor file to install/update merb:edge
First, make sure you have the latest merb.thor file. Run this command again.
cd ~/documents/code/merb/sources
curl -L http://merbivore.com/merb.thor > merb.thor
# or alternatively you can run
thor merb:tasks:update
Install/update merb:edge
cd ~/documents/code/merb/sources
#sudo thor merb:edge --install #used this previously but now using the 3 following lines so that I get the merb-plugins gems like merb_helpers in there as well.
sudo thor merb:edge:core --install
sudo thor merb:edge:more --install
sudo thor merb:edge:plugins --install
You will get an output similar to this if installing for the first time.
Install datamapper as your orm
Aside:
What is an orm? It’s an object-realtional_mapping tool/language. ActiveRecord is the most well known if you are a rails developer. Datamapper seems to be the current most popular choice for merb developers (but don’t quote me on that. Merb is highly configurable and different orms - like ActiveRecord - might server your particular needs better). However, datamapper is a safe bet for now with it’s goal to be fast, thread-safe and feature rich. Plus, thor supports it. On a final note, if you don’t know which orm to use, use datamapper. It is awesome. Let wycats show you why.
cd ~/documents/code/merb/sources
sudo thor merb:edge:dm_core --install
sudo thor merb:edge:dm_more --install
#the following worked on my computer already installed with datamapper, but did not work on a fresh install on a server. Therefore, use the two lines above.
#thor dm:gems:wipe #to clean out any old datamapper gems
#thor dm:clone #to pull down the github datamapper repositories
#cd dm
#thor dm:install #to install the latest datamapper gems
However, the most recent Thor file did not install merb_datamapper (Sept 23 2008), therefore I also did:
cd ~/sources
git clone git://github.com/sam/dm-more.git
cd dm-more/merb_datamapper
rake install
Also, the most recent data_objects and do_mysql was not installed correctly (I was getting the uninitialized constant DataObjects::URI (NameError) like you see here)so I also did:
cd ~/sources
git clone git://github.com/sam/do.git
cd do
rake install
7 Responses | September 17, 2008
use the command tzselect
I was having issues with my rails-based cronjobs inserting different dates because of a difference between the date on my server and the date on my rails app (using Los Angeles time). I needed to make them match to fix this problem so I changed the time on my server using tzselect.
Nevermind, that didn’t really work the way I thought it would. I ended up just changing the crontab runtime to reflect the difference in time between LA and London.
No Comments | September 17, 2008