<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Taming the Wild Blue Ether &#187; On the Ground</title> <atom:link href="http://wildblueether.com/category/on-the-ground/feed/" rel="self" type="application/rss+xml" /><link>http://wildblueether.com</link> <description>making sense of the Internet and software development</description> <lastBuildDate>Fri, 24 Jun 2011 18:27:55 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>On the Rails: Set Up Ruby, Rails and PostgreSQL on Ubuntu 10.04</title><link>http://wildblueether.com/2010/05/31/on-the-rails-set-up-ruby-rails-and-postgresql-on-ubuntu-10-04/</link> <comments>http://wildblueether.com/2010/05/31/on-the-rails-set-up-ruby-rails-and-postgresql-on-ubuntu-10-04/#comments</comments> <pubDate>Mon, 31 May 2010 09:51:25 +0000</pubDate> <dc:creator>Jeremy Merrill</dc:creator> <category><![CDATA[On the Ground]]></category><guid
isPermaLink="false">http://www.wildblueether.com/?p=338</guid> <description><![CDATA[Hello again. Today we are going to be installing Ruby (1.8.7 patchlevel 174), RubyGems (1.3.7), Ruby on Rails (2.3.8) and PostgreSQL (8.4) on Ubuntu Desktop 32-bit 10.04 (Lucid Lynx) LTS (Long-Term Support release). This runthrough assumes a clean install of Lucid, with all available updates/upgrades applied. We are going to be more or less following the instructions [...]]]></description> <content:encoded><![CDATA[<div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwildblueether.com%2F2010%2F05%2F31%2Fon-the-rails-set-up-ruby-rails-and-postgresql-on-ubuntu-10-04%2F"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwildblueether.com%2F2010%2F05%2F31%2Fon-the-rails-set-up-ruby-rails-and-postgresql-on-ubuntu-10-04%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br
/> </a></div><p>Hello again. Today we are going to be installing <a
href="http://www.ruby-lang.org/en/" target="_blank">Ruby</a> (1.8.7 patchlevel 174), <a
href="http://rubygems.org/" target="_blank">RubyGems</a> (1.3.7), <a
href="http://rubyonrails.org/" target="_blank">Ruby on Rails</a> (2.3.8) and <a
href="http://www.postgresql.org/" target="_blank">PostgreSQL</a> (8.4) on <a
href="http://www.ubuntu.com/" target="_blank">Ubuntu</a> <a
href="http://www.ubuntu.com/desktop" target="_blank">Desktop</a> 32-bit 10.04 (Lucid Lynx) LTS (Long-Term Support release). This runthrough assumes a clean install of Lucid, with all available updates/upgrades applied.</p><p>We are going to be more or less following the instructions found in a <a
href="http://gist.github.com/416372" target="_blank">gist</a> from <a
href="http://marcchung.com/" target="_blank">Marc Chung</a>, with only minor additions and corrections where appropriate. We will be using the wonderful <a
href="http://rvm.beginrescueend.com/" target="_blank">Ruby Version Manager</a> (rvm) to install Ruby and RubyGems.</p><p><strong><span
style="text-decoration: underline;">Install Packages</span></strong></p><p>First, let&#8217;s install the Ubuntu packages we&#8217;ll need to install rvm, Ruby and RubyGems. While we&#8217;re at it, we&#8217;ll also install our database server (PostgreSQL) and two packages (libxslt1-dev and libpq-dev) we&#8217;ll need later to build the native extensions to two of our gems (nokogiri and pg, respectively). Run the following command from a Terminal window:</p><pre class="brush: plain; title: ; notranslate">sudo apt-get install curl git-core bison build-essential zlib1g-dev libssl-dev libreadline6-dev libxml2-dev autoconf libxslt1-dev libpq-dev postgresql</pre><p>Type your user password when prompted. The first two packages are needed to get rvm; the rest, except for the last three, are needed to build Ruby and RubyGems.</p><p><strong><span
style="text-decoration: underline;">Install rvm</span></strong></p><p>Now, let&#8217;s download and install rvm. To accomplish this, run the following commands in order:</p><pre class="brush: plain; title: ; notranslate">curl http://rvm.beginrescueend.com/releases/rvm-install-head &gt;rvm-install-head
chmod a+x rvm-install-head
./rvm-install-head</pre><p>This command sequence saves a local copy of an installer script from the rvm site and runs it. The installer script, in turn, grabs rvm from a repository on <a
href="http://github.com/" target="_blank">GitHub</a> and installs it.</p><p>You&#8217;ll see some messages when rvm is done installing, telling you to modify your <strong>~/.bashrc</strong> file.  I modified mine as follows.  I opened up the file in pico:</p><pre class="brush: plain; title: ; notranslate">pico ~/.bashrc</pre><p>I commented out line 6:</p><pre class="brush: plain; title: ; notranslate">[ -z &quot;$PS1&quot; ] &amp;&amp; return</pre><p>I inserted a new line 7:</p><pre class="brush: plain; title: ; notranslate">if [[ ! -z &quot;$PS1&quot; ]] ; then</pre><p>I then went to the end of the file and appended these two lines:</p><pre class="brush: plain; title: ; notranslate">
[[ -s $HOME/.rvm/scripts/rvm ]] &amp;&amp; source $HOME/.rvm/scripts/rvm
fi
</pre><p>I saved the file with Ctrl-O, exited pico with Ctrl-X, and then closed and reopened my Terminal.</p><p><strong><span
style="text-decoration: underline;">Install Ruby and RubyGems</span></strong></p><p>Next, we&#8217;ll download and install the particular &#8220;ruby&#8221; (singular form of &#8220;rubies&#8221;) that we mentioned above, along with the RubyGems gem management software and two actual gems &#8212; <a
href="http://rake.rubyforge.org/" target="_blank">Rake</a> and <a
href="http://rdoc.rubyforge.org/" target="_blank">RDoc</a>. Run the following:</p><pre class="brush: plain; title: ; notranslate">rvm install 1.8.7-p174
rvm use 1.8.7-p174
rvm --default 1.8.7-p174
</pre><p>The second command tells rvm that the ruby we just installed is, in fact, the ruby we want to use and the one that will respond when we type &#8220;ruby&#8221; on the command line. The third sets that ruby as the default, so we don&#8217;t have to type &#8220;rvm use &lt;whatever&gt;&#8221; every time we open a new Terminal, which is just an unnecessary step if we only have one ruby installed.</p><p><strong><span
style="text-decoration: underline;">Trust, But Verify</span></strong></p><p>Before we go any further, let&#8217;s verify that we have, in fact, installed the correct versions of ruby, rubygems, rake and rdoc. The following command/response sequence should demonstrate that this is true (The $ represents the prompt):</p><pre class="brush: plain; title: ; notranslate">
$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux]
$ gem -v
1.3.7
$ gem list

*** LOCAL GEMS ***

rake (0.8.7)
rdoc (2.5.8)
</pre><p>Assuming we&#8217;re all good, let&#8217;s continue.</p><p><strong><span
style="text-decoration: underline;">Install Bundler and Rails</span></strong></p><p>Now, we&#8217;re ready to install <a
href="http://gembundler.com/" target="_blank">Bundler</a> and then the Ruby on Rails web application development framework. What&#8217;s Bundler, you ask? Good question. It&#8217;s a system to help you manage the gems required by your applications in a shared production environment (when you have more than one application running on a single server).</p><p>So, let&#8217;s run the following:</p><pre class="brush: plain; title: ; notranslate">
gem install bundler
gem install rails</pre><p>Again, let&#8217;s verify:</p><pre class="brush: plain; title: ; notranslate">
$ rails -v
Rails 2.3.8
$ gem list

*** LOCAL GEMS ***

actionmailer (2.3.8)
actionpack (2.3.8)
activerecord (2.3.8)
activeresource (2.3.8)
activesupport (2.3.8)
bundler (0.9.25)
rack (1.1.0)
rails (2.3.8)
rake (0.8.7)
rdoc (2.5.8)
</pre><p>Theoretically, the above list shows all the gems that we&#8217;ll ever need to install locally with the &#8220;gem install&#8221; command to develop an application using Rails 2.3.8. Any and all further gems required by our app will be installed for us (locally, in production, and everywhere else our app might live) by Bundler. We&#8217;ll tell Bundler about all of these other gems in a moment.</p><p><strong><span
style="text-decoration: underline;">Create Rails App, Insert Gemfile</span></strong></p><p>Now, let&#8217;s set up a new default Rails app, specifying PostgreSQL as the database:</p><pre class="brush: plain; title: ; notranslate">mkdir workspace
cd workspace
rails rails238test -d postgresql
cd rails238test</pre><p>At this point, we&#8217;re ready to add a Gemfile to the project. As its name might suggest, this file lists all of the gems our application needs to run &#8212; on our local development machine, on our production server, and everywhere in between. Paste the following into a new text file in gedit, and save it to your project&#8217;s root (<strong>~/workspace/rails238test</strong>) under the name &#8220;Gemfile&#8221;:</p><pre class="brush: plain; title: ; notranslate">
source &quot;http://rubygems.org&quot;

gem &quot;rails&quot;, &quot;2.3.8&quot;
gem &quot;pg&quot;, &quot;0.9.0&quot;
gem &quot;capistrano&quot;
gem &quot;heroku&quot;

gem &quot;rack&quot;, &quot;1.1.0&quot;
gem &quot;clearance&quot;
gem &quot;fastercsv&quot;

group :test do
  gem &quot;rspec&quot;
  gem &quot;rspec-rails&quot;, &quot;1.3.2&quot;
  gem &quot;faker&quot;
  gem &quot;database_cleaner&quot;
  gem &quot;capybara&quot;
  gem &quot;cucumber&quot;
  gem &quot;cucumber-rails&quot;
  gem &quot;test-unit&quot;

  gem &quot;factory_girl&quot;
  gem &quot;formtastic&quot;
  gem &quot;email_spec&quot;
end
</pre><p>As you might guess from taking a gander at this list of gems, we&#8217;re going to be getting into all kinds of cool new things here. We&#8217;re installing the PostgreSQL database adapter gem, which is obviously necessary and not new to us. We&#8217;re also going to be using Capistrano to deploy our app &#8212; again, not new.</p><p>But, other than those two, everything else on the list is something we haven&#8217;t dealt with before. We&#8217;ll be getting into unit testing with <a
href="http://rubyforge.org/projects/test-unit/" target="_blank">Test::Unit</a> and <a
href="http://rdoc.info/projects/thoughtbot/factory_girl" target="_blank">Factory Girl</a>, behavior-driven development (BDD) with <a
href="http://rspec.info/" target="_blank">RSpec</a> and <a
href="http://cukes.info/">Cucumber</a>, auto-generation of dummy data with <a
href="http://faker.rubyforge.org/" target="_blank">Faker</a>, integration testing with <a
href="http://github.com/jnicklas/capybara" target="_blank">Capybara</a>, and more. We&#8217;ll also be deploying our app to that great <span
style="text-decoration: line-through;">gig</span> Ruby application platform in the sky &#8212; <a
href="http://heroku.com/" target="_blank">Heroku</a>!</p><p><strong><span
style="text-decoration: underline;">Bundle</span></strong></p><p>Let&#8217;s set this sucker off. Run the following:</p><pre class="brush: plain; title: ; notranslate">bundle install</pre><p>This command will download and install all of the gems specified in our Gemfile, along with their dependencies. Four of them require native extensions to be built. Of those, two require the development libraries we installed earlier as Ubuntu packages.</p><p>Assuming all went well, our app now has a &#8220;bundle&#8221; of <span
style="text-decoration: line-through;">joy</span> gems associated with it.</p><p><strong><span
style="text-decoration: underline;">Replace Database Config</span></strong></p><p>Next, we&#8217;ll replace the contents of our <strong>~/workspace/rails238test/config/database.yml</strong> file with the following:</p><pre class="brush: plain; title: ; notranslate">
development:
  adapter: postgresql
  encoding: utf8
  database: rails238test_development
  username: postgres
  password:
  host: localhost

# Warning: The database defined as &quot;test&quot; will be erased and
# re-generated from your development database when you run &quot;rake&quot;.
# Do not set this db to the same as development or production.
test: &amp;TEST
  adapter: postgresql
  encoding: utf8
  database: rails238test_test
  username: postgres
  password:
  host: localhost
</pre><p><strong><span
style="text-decoration: underline;">Set Up RSpec, Cucumber &amp; Capybara</span></strong></p><p>From your project root (<strong>~/workspace/rails238test</strong>), run the following:</p><pre class="brush: plain; title: ; notranslate">
$ ./script/generate rspec
Configuring rspec and rspec-rails gems in config/environments/test.rb ...

      exists  lib/tasks
      create  lib/tasks/rspec.rake
      create  script/autospec
      create  script/spec
      create  spec
      create  spec/rcov.opts
      create  spec/spec.opts
      create  spec/spec_helper.rb
$ ./script/generate cucumber --rspec --capybara
       force  config/database.yml
      create  config/cucumber.yml
      create  config/environments/cucumber.rb
      create  script/cucumber
      create  features/step_definitions
      create  features/step_definitions/web_steps.rb
      create  features/support
      create  features/support/paths.rb
      create  features/support/env.rb
      exists  lib/tasks
      create  lib/tasks/cucumber.rake
</pre><p>Those two steps bootstrap our Rails app for use with RSpec, Cucumber and Capybara. They create some files, and add a couple lines to our database.yml file.</p><p><strong><span
style="text-decoration: underline;">Generate a Cucumber Feature and a Scaffold</span></strong></p><p>Now, let&#8217;s run the following (again, from our project root):</p><pre class="brush: plain; title: ; notranslate">
$ ./script/generate feature book title:string author:string publisher:string copyright_year:string isbn:string
      exists  features/step_definitions
      create  features/manage_books.feature
      create  features/step_definitions/book_steps.rb
$ ./script/generate scaffold book title:string author:string publisher:string copyright_year:string isbn:string
      exists  app/models/
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/books
      exists  app/views/layouts/
      exists  test/functional/
      exists  test/unit/
      create  test/unit/helpers/
      exists  public/stylesheets/
      create  app/views/books/index.html.erb
      create  app/views/books/show.html.erb
      create  app/views/books/new.html.erb
      create  app/views/books/edit.html.erb
      create  app/views/layouts/books.html.erb
      create  public/stylesheets/scaffold.css
      create  app/controllers/books_controller.rb
      create  test/functional/books_controller_test.rb
      create  app/helpers/books_helper.rb
      create  test/unit/helpers/books_helper_test.rb
       route  map.resources :books
  dependency  model
      exists    app/models/
      exists    test/unit/
      exists    test/fixtures/
      create    app/models/book.rb
      create    test/unit/book_test.rb
      create    test/fixtures/books.yml
      create    db/migrate
      create    db/migrate/20100531032247_create_books.rb
</pre><p>All this did was auto-generate a feature, along with a scaffold matching that feature. In our case, the feature we want to implement is &#8220;basic CRUD functions for data on books&#8221;.  The scaffold we generated implements that feature (that part should look familiar if you&#8217;ve seen <a
href="http://www.wildblueether.com/2009/12/15/setting-up-rails-and-postgresql-on-snow-leopard/">my</a> <a
href="http://www.wildblueether.com/2009/12/29/on-the-rails-create-a-simple-crud-app-set-up-a-database/">earlier</a> <a
href="http://www.wildblueether.com/2009/12/31/on-the-rails-install-apache-2-and-passenger-locally/">series</a> <a
href="http://www.wildblueether.com/2009/12/31/on-the-rails-set-up-git-repos-locally-and-on-github/">of</a> <a
href="http://www.wildblueether.com/2010/01/08/on-the-rails-bootstrap-a-rackspace-cloud-server/">posts</a> <a
href="http://www.wildblueether.com/2010/01/10/on-the-rails-capify-and-deploy/">on</a> getting started with Rails).</p><p><strong><span
style="text-decoration: underline;">Create Database &amp; Schema</span></strong></p><p>Now, we need to get our database and schema created, so that we can test what we just generated. Before we do this, we need to change one of our PostgreSQL config files to allow Rails to connect to it. Run the following:</p><pre class="brush: plain; title: ; notranslate">sudo pico /etc/postgresql/8.4/main/pg_hba.conf</pre><p>Scroll down to the bottom of the file, and you&#8217;ll see a section that looks like this:</p><pre class="brush: plain; title: ; notranslate">
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# &quot;local&quot; is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5
</pre><p>Make it look like this:</p><pre class="brush: plain; title: ; notranslate">
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# &quot;local&quot; is for Unix domain socket connections only
local   all         all                               trust
# IPv4 local connections:
host    all         all         127.0.0.1/32          trust
# IPv6 local connections:
host    all         all         ::1/128               trust
</pre><p>It took me a while, but I finally found <a
href="http://oldwiki.rubyonrails.org/rails/pages/PostgreSQL" target="_blank">an old Ruby on Rails wiki page</a> that explains why this step is needed, and why the solution we applied in <a
href="http://www.wildblueether.com/2010/01/10/on-the-rails-capify-and-deploy/">a previous post</a> (changing only the &#8220;local&#8221; line of that section) doesn&#8217;t work.</p><p>It turns out that Rails connects to the local PostgreSQL server via TCP sockets, not UNIX domain sockets. (So why did our previous solution work before? It&#8217;s a mystery to me at the moment. Maybe I&#8217;ll discover the answer and write about it in a future post.)</p><p>This time, we&#8217;re trying to connect to the server as, and create a database for, the PostgreSQL user &#8220;postgres&#8221; &#8212; the only one that exists right now, which doesn&#8217;t have a password set.</p><p>The change we just made opens up the ability for any application, running locally as any UNIX user, connecting on any UNIX domain socket or TCP socket (using IPv4 or v6), to connect to the PostgreSQL server as any PostgreSQL user, without a password.</p><p>This level of security obviously will not do in a staging or production environment, but it will be fine for our local development purposes.</p><p>So, let&#8217;s save the config file with Ctrl-O, exit pico with Ctrl-X, and tell PostgreSQL to reload its configuration files with the following command:</p><pre class="brush: plain; title: ; notranslate">sudo su postgres -c &quot;/usr/lib/postgresql/8.4/bin/pg_ctl reload -D /var/lib/postgresql/8.4/main&quot;</pre><p>Now, let&#8217;s create our database:</p><pre class="brush: plain; title: ; notranslate">
$ rake db:create --trace
(in /home/jeremy/workspace/rails238test)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
</pre><p>And our schema:</p><pre class="brush: plain; title: ; notranslate">
$ rake db:migrate --trace
(in /home/jeremy/workspace/rails238test)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  CreateBooks: migrating ====================================================
-- create_table(:books)
NOTICE:  CREATE TABLE will create implicit sequence &quot;books_id_seq&quot; for serial column &quot;books.id&quot;
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index &quot;books_pkey&quot; for table &quot;books&quot;
   -&gt; 0.1953s
==  CreateBooks: migrated (0.1960s) ===========================================

** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
</pre><p><strong><span
style="text-decoration: underline;">Test Models</span></strong></p><p>First, let&#8217;s test our specs:</p><pre class="brush: plain; title: ; notranslate">
$ rake spec --trace
(in /home/jeremy/workspace/rails238test)
** Invoke spec (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
NOTICE:  CREATE TABLE will create implicit sequence &quot;books_id_seq&quot; for serial column &quot;books.id&quot;
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index &quot;books_pkey&quot; for table &quot;books&quot;
** Execute spec
</pre><p>And now, let&#8217;s test our features:</p><pre class="brush: plain; title: ; notranslate">
$ rake cucumber --trace
(in /home/jeremy/workspace/rails238test)
** Invoke cucumber (first_time)
** Invoke cucumber:ok (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
NOTICE:  CREATE TABLE will create implicit sequence &quot;books_id_seq&quot; for serial column &quot;books.id&quot;
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index &quot;books_pkey&quot; for table &quot;books&quot;
** Execute cucumber:ok
/home/jeremy/.rvm/rubies/ruby-1.8.7-p174/bin/ruby -I &quot;/home/jeremy/.rvm/gems/ruby-1.8.7-p174/gems/cucumber-0.7.3/lib:lib&quot; &quot;/home/jeremy/.rvm/gems/ruby-1.8.7-p174/gems/cucumber-0.7.3/bin/cucumber&quot;  --profile default
Using the default profile...
...............

2 scenarios (2 passed)
15 steps (15 passed)
0m1.003s
** Execute cucumber
</pre><p><strong><span
style="text-decoration: underline;">Create Local Git Repo, Prepare for Heroku</span></strong></p><p>So, now, let&#8217;s Git-ify this thing (again, make sure you&#8217;re in <strong>~/workspace/rails238test</strong>). First, let&#8217;s create a <strong>.gitignore</strong> file so that we can exclude certain files from our Git repository:</p><pre class="brush: plain; title: ; notranslate">
cat&lt;&lt;EOF &gt;.gitignore
&gt; .bundle
&gt; .gitignore
&gt; EOF
</pre><p>We just excluded our .bundle directory, and the .gitignore file itself. Now, let&#8217;s run the following commands in order:</p><pre class="brush: plain; title: ; notranslate">
git init
git config --global user.email &lt;your_email_address&gt;
git config --global user.name &quot;&lt;your_name&gt;&quot;
git add .
git commit -m 'first commit'
</pre><p>Our app is now ready to go up to Heroku. Before we can do that, we&#8217;ll need an account on Heroku. Go <a
href="http://api.heroku.com/signup" target="_blank">here</a> to sign up for a free account.</p><p>Once we&#8217;ve done that, we&#8217;ll need to generate an SSH keypair:</p><pre class="brush: plain; title: ; notranslate">ssh-keygen -C &quot;&lt;your_email_address&gt;&quot; -t rsa</pre><p><strong><span
style="text-decoration: underline;">Create App on Heroku, Deploy</span></strong></p><p>OK. Let&#8217;s get this baby onto Heroku! First, we&#8217;ll need to create the app on Heroku:</p><pre class="brush: plain; title: ; notranslate">
$ heroku create &lt;some_unique_identifier&gt;-rails238test
Enter your Heroku credentials.
Email: &lt;your_email_address&gt;
Password: &lt;your_heroku_password&gt;
Uploading ssh public key /home/jeremy/.ssh/id_rsa.pub
Creating &lt;some_unique_identifier&gt;-rails238test.... done
Created http://&lt;some_unique_identifier&gt;-rails238test.heroku.com/ | git@heroku.com:&lt;some_unique_identifier&gt;-rails238test.git
</pre><p>Next, we&#8217;ll add our remote destination to our git repo, and push our code up there:</p><pre class="brush: plain; title: ; notranslate">
$ git remote add heroku git@heroku.com:&lt;some_unique_identifier&gt;-rails238test.git
$ git push heroku master
The authenticity of host 'heroku.com (174.129.212.2)' can't be established.
RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'heroku.com,174.129.212.2' (RSA) to the list of known hosts.
Counting objects: 116, done.
Compressing objects: 100% (100/100), done.
Writing objects: 100% (116/116), 97.84 KiB, done.
Total 116 (delta 10), reused 0 (delta 0)

-----&gt; Heroku receiving push
-----&gt; Gemfile detected, running Bundler
-----&gt; Bundler works best on the Bamboo stack.  Please migrate your app:

http://docs.heroku.com/bamboo

       Unresolved dependencies detected; Installing...
       Fetching source index from http://rubygems.org/
       Resolving dependencies
       Installing actionmailer (2.3.8) from rubygems repository at http://rubygems.org/
... the rest of our gems ...
       Your bundle is complete!
       Locking environment
-----&gt; Rails app detected
       Compiled slug size is 11.2MB
-----&gt; Launching......... done
       http://&lt;some_unique_identifier&gt;-rails238test.heroku.com deployed to Heroku

To git@heroku.com:&lt;some_unique_identifier&gt;-rails238test.git
 * [new branch]      master -&gt; master
</pre><p>Hmm. Looks like we should have specified the Bamboo stack when we created the app on Heroku. But that&#8217;s OK; we can migrate to another stack. Before we do that, let&#8217;s set up our app&#8217;s database on Heroku:</p><pre class="brush: plain; title: ; notranslate">
$ heroku rake db:migrate
(in /disk1/home/slugs/&lt;some_other_unique_identifying_string&gt;/mnt)
==  CreateBooks: migrating ====================================================
-- create_table(:books)
   -&gt; 0.0163s
==  CreateBooks: migrated (0.0164s) ===========================================
</pre><p>It&#8217;s now time for the moment of truth. Let&#8217;s point our browser at <strong>&lt;some_unique_identifier&gt;-rails238test.heroku.com/books</strong>, and see what we get!</p><p>If you see a page that says &#8220;Listing books&#8221; at the top, you&#8217;re in business!</p><p>Though we probably don&#8217;t need to (given that we&#8217;re just running our simple &#8220;books&#8221; CRUD app), let&#8217;s migrate to the Bamboo stack like Heroku <a
href="http://docs.heroku.com/bamboo" target="_blank">says</a>:</p><pre class="brush: plain; title: ; notranslate">
$ heroku stack:migrate bamboo-ree-1.8.7
-----&gt; Preparing to migrate &lt;some_unique_identifier&gt;-rails238test
       aspen-mri-1.8.6 -&gt; bamboo-ree-1.8.7

       NOTE: You must specify ALL gems (including Rails) in manifest

       Please read the migration guide:

http://docs.heroku.com/bamboo

-----&gt; Migration prepared.
       Run 'git push heroku master' to execute migration.
$ git push heroku master
Warning: Permanently added the RSA host key for IP address '75.101.145.87' to the list of known hosts.
Everything up-to-date
$ heroku stack
* aspen-mri-1.8.6
  bamboo-ree-1.8.7 (beta) (prepared, will migrate on next git push)
  bamboo-mri-1.9.1 (beta)
</pre><p>It won&#8217;t migrate unless it actually has some code changes to push up. So, we&#8217;ll create a dummy commit and push that:</p><pre class="brush: plain; title: ; notranslate">
$ echo &gt;&gt; Rakefile &amp;&amp; git commit -a -m &quot;migrating to bamboo stack&quot;
[master 48624c5] migrating to bamboo stack
 1 files changed, 1 insertions(+), 0 deletions(-)
$ git push heroku master
Warning: Permanently added the RSA host key for IP address '75.101.163.44' to the list of known hosts.
Counting objects: 5, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 305 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)

-----&gt; Heroku receiving push
-----&gt; Migrating from aspen-mri-1.8.6 to bamboo-ree-1.8.7

-----&gt; Gemfile detected, running Bundler
       Unresolved dependencies detected; Installing...
       Fetching source index from http://rubygems.org/
       Using rake (0.8.7) from system gems
       Installing activesupport (2.3.8) from rubygems repository at http://rubygems.org/
... the rest of our gems ...
       Your bundle is complete! Use `bundle show gemname` to see where a bundled gem is installed.
       Locking environment
-----&gt; Rails app detected
       Compiled slug size is 11.2MB
-----&gt; Launching............ done
       http://&lt;some_unique_identifier&gt;-rails238test.heroku.com deployed to Heroku

-----&gt; Migration complete, your app is now running on bamboo-ree-1.8.7

To git@heroku.com:&lt;some_unique_identifier&gt;-rails238test.git
   87aa8d5..48624c5  master -&gt; master
</pre><p><strong><span
style="text-decoration: underline;">Conclusion</span></strong></p><p>Success! We&#8217;re done!</p><p>Of course, we&#8217;ve just taken &#8220;one small step for [a] man, [but] one giant leap for Web-dev-kind.&#8221; There&#8217;s plenty more fun to be had exploring Ruby, Rails, TDD and BDD, and running apps on PaaS (Platform-as-a-Service) clouds like Heroku. I&#8217;ll be sure to chronicle more of my adventures here. Until next time, happy coding!</p> ]]></content:encoded> <wfw:commentRss>http://wildblueether.com/2010/05/31/on-the-rails-set-up-ruby-rails-and-postgresql-on-ubuntu-10-04/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>On the Rails: Capify and Deploy!</title><link>http://wildblueether.com/2010/01/10/on-the-rails-capify-and-deploy/</link> <comments>http://wildblueether.com/2010/01/10/on-the-rails-capify-and-deploy/#comments</comments> <pubDate>Mon, 11 Jan 2010 05:55:11 +0000</pubDate> <dc:creator>Jeremy Merrill</dc:creator> <category><![CDATA[On the Ground]]></category><guid
isPermaLink="false">http://www.wildblueether.com/?p=286</guid> <description><![CDATA[Ready to get our app onto that Rackspace Cloud Server? Me too; let&#8217;s do it! Install First, on our Mac, we need to install Capistrano, which will deploy our app for us once we have it set up. It&#8217;s a Ruby gem. Do the following to get it: Capify Now, let&#8217;s run these commands from [...]]]></description> <content:encoded><![CDATA[<div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwildblueether.com%2F2010%2F01%2F10%2Fon-the-rails-capify-and-deploy%2F"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwildblueether.com%2F2010%2F01%2F10%2Fon-the-rails-capify-and-deploy%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br
/> </a></div><p>Ready to get our app onto that Rackspace Cloud Server? Me too; let&#8217;s do it!</p><p><strong><span
style="text-decoration: underline;">Install</span></strong></p><p>First, on our Mac, we need to install <a
href="http://www.capify.org/index.php/Getting_Started" target="_blank">Capistrano</a>, which will deploy our app for us once we have it set up. It&#8217;s a Ruby gem. Do the following to get it:</p><pre class="brush: plain; title: ; notranslate">sudo gem sources -a http://gems.github.com/
sudo gem install capistrano</pre><p><strong><span
style="text-decoration: underline;">Capify</span></strong></p><p>Now, let&#8217;s run these commands from our home directory:</p><pre class="brush: plain; title: ; notranslate">cd workspace/railstest
capify .</pre><p>Capistrano will add two files to our app, <strong>Capfile</strong> and <strong>config/deploy.rb</strong>. Let&#8217;s edit config/deploy.rb:</p><pre class="brush: plain; title: ; notranslate">pico config/deploy.rb</pre><p><a
href="http://www.capify.org/index.php/From_The_Beginning" target="_blank">Here</a> is one place we can look for help in figuring out what to put in this file so that Capistrano will know where and how to deploy our app.</p><p>Below is what our config/deploy.rb file ends up looking like:</p><pre class="brush: plain; title: ; notranslate">
set :application, &quot;railstest&quot;
set :repository,  &quot;git@github.com:your_github_username/railstest.git&quot;

# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
set :deploy_to, &quot;/var/local/#{application}&quot;

# If you aren't using Subversion to manage your source code, specify
# your SCM below:
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

set :deploy_via, :remote_cache
set :branch, &quot;master&quot;

set :passenger_conf, true
set :user, &quot;app&quot; # Login as?
set :runner, &quot;app&quot; # Run ./script as?
set :use_sudo, false

set :domain, &quot;rails.example.com&quot;

role :web, domain                          # Your HTTP server, Apache/etc
role :app, domain                          # This may be the same as your `Web` server
role :db,  domain, :primary =&gt; true        # This is where Rails migrations will run
#role :db,  &quot;your slave db-server here&quot;

set :rails_env, &quot;production&quot;

# If you are using Passenger mod_rails uncomment this:
# if you're still using the script/reapear helper you will need
# these http://github.com/rails/irs_process_scripts

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles =&gt; :app, :except =&gt; { :no_release =&gt; true } do
    run &quot;#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}&quot;
  end
end
</pre><p><strong><span
style="text-decoration: underline;">Deploy</span></strong></p><p>Now, we&#8217;re ready to run &#8220;cap&#8221; and actually do some things. <img
src='http://wildblueether.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Let&#8217;s follow some steps in the handy <a
href="http://www.capify.org/index.php/From_The_Beginning" target="_blank">guide</a> referenced above:</p><pre class="brush: plain; title: ; notranslate">cap deploy:setup
cap deploy:check
cap deploy:update</pre><p><strong><span
style="text-decoration: underline;">Note</span>:</strong> The &#8220;update&#8221; task failed for me the first time I tried it, and I think the &#8220;<strong>Known Hosts List</strong>&#8221; section at the bottom of <a
href="http://github.com/guides/deploying-with-capistrano" target="_blank">this page</a> explains why. I solved the problem by SSHing into the server and doing the following:</p><pre class="brush: plain; title: ; notranslate">su app
git ls-remote git@github.com:your_github_username/railstest.git master</pre><p>You should see something like:</p><pre class="brush: plain; title: ; notranslate">
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
</pre><p>Type &#8220;yes&#8221;, and press Enter, and you should see something like:</p><pre class="brush: plain; title: ; notranslate">
Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
502d44c77a98c812eff27e97d542f47ed891fad1        refs/heads/master
</pre><p>I tried &#8220;cap deploy:update&#8221; again from my Mac and it succeeded.</p><p>OK, let&#8217;s continue. We&#8217;re already on the server, in a shell as the &#8220;app&#8221; user, so let&#8217;s try this:</p><pre class="brush: plain; title: ; notranslate">cd /var/local/railstest/current
rake RAILS_ENV=production db:schema:load</pre><p><strong><span
style="text-decoration: underline;">Note</span>:</strong> This one didn&#8217;t work for me at first either. I found an explanation <a
href="http://semweb.weblog.ub.rug.nl/node/61" target="_blank">here</a>, which seems to line up with what the PostgreSQL manual <a
href="http://www.postgresql.org/docs/8.4/static/client-authentication.html" target="_blank">says</a>. Evidently, the default is for postgresql to only allow UNIX socket connections as a database user with the same name as the operating system user. In our case, we&#8217;re running rake as &#8220;app&#8221;, and rake is trying to connect to postgresql as &#8220;railstest&#8221;, which isn&#8217;t going to work under the default setup. So, let&#8217;s change the setup. Type &#8220;exit&#8221; to get back to your root shell. As root, do this:</p><pre class="brush: plain; title: ; notranslate">pico /etc/postgresql/8.4/main/pg_hba.conf</pre><p>Comment out the line that says:</p><pre class="brush: plain; title: ; notranslate">local all all ident sameuser</pre><p>and add a line right below it that says:</p><pre class="brush: plain; title: ; notranslate">local all all trust</pre><p>Then, run:</p><pre class="brush: plain; title: ; notranslate">sudo su postgres -c &quot;/usr/lib/postgresql/8.4/bin/pg_ctl reload -D /var/lib/postgresql/8.4/main&quot;</pre><p>to have postgresql reload the config file we just edited. Now, let&#8217;s try this step again:</p><pre class="brush: plain; title: ; notranslate">su app
cd /var/local/railstest/current
rake RAILS_ENV=production db:schema:load</pre><p>It works! Next, do:</p><pre class="brush: plain; title: ; notranslate">./script/console production
app.get(&quot;/&quot;)</pre><p>I got a 404 from this, which apparently isn&#8217;t a bad thing in our case, because we haven&#8217;t configured our app to return anything from that location in production mode.</p><p>Next, opening up a web browser on your Mac and browsing to:</p><pre class="brush: plain; title: ; notranslate">http://rails.example.com/javascripts/prototype.js</pre><p>should return what you would expect.</p><p>So, now that we&#8217;ve checked every step of the process, let&#8217;s run the whole she-bang. In your Mac Terminal, do:</p><pre class="brush: plain; title: ; notranslate">cap deploy</pre><p>If it works, then we are now at the moment of truth. In our web browser, let&#8217;s browse to:</p><pre class="brush: plain; title: ; notranslate">http://rails.example.com/books</pre><p>Our app should come up! Success! We&#8217;re done! WOO-HOO!!!</p><p><strong><span
style="text-decoration: underline;">Conclusion</span></strong></p><p>Thanks for joining me on this journey (if there&#8217;s been anyone out there reading this). It&#8217;s actually been quite a ride for me, a PHP/MySQL monkey by trade. I hope you&#8217;ve had as much fun learning about this stuff as I have. No doubt there&#8217;s a better way to do some of the things described in this series. I&#8217;ll probably update some of what I&#8217;ve written with better methods in future posts. And I&#8217;m sure there will be plenty of all-new adventures &#8220;On the Rails&#8221; in the future. If you have something to share, please feel free to drop me a line. Thanks again, and see you down the road!</p> ]]></content:encoded> <wfw:commentRss>http://wildblueether.com/2010/01/10/on-the-rails-capify-and-deploy/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>On the Rails: Bootstrap a Rackspace Cloud Server</title><link>http://wildblueether.com/2010/01/08/on-the-rails-bootstrap-a-rackspace-cloud-server/</link> <comments>http://wildblueether.com/2010/01/08/on-the-rails-bootstrap-a-rackspace-cloud-server/#comments</comments> <pubDate>Fri, 08 Jan 2010 07:37:26 +0000</pubDate> <dc:creator>Jeremy Merrill</dc:creator> <category><![CDATA[On the Ground]]></category><guid
isPermaLink="false">http://www.wildblueether.com/?p=269</guid> <description><![CDATA[I&#8217;m going to assume you already have a Rackspace Cloud account. (If you don&#8217;t, I&#8217;ll leave it to you to rectify the situation.) Create a Server Follow these steps to create a Rackspace Cloud Server: Log in to the control panel at manage.rackspacecloud.com. Click on Hosting in the left nav bar, then Cloud Servers. Click [...]]]></description> <content:encoded><![CDATA[<div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwildblueether.com%2F2010%2F01%2F08%2Fon-the-rails-bootstrap-a-rackspace-cloud-server%2F"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwildblueether.com%2F2010%2F01%2F08%2Fon-the-rails-bootstrap-a-rackspace-cloud-server%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br
/> </a></div><p>I&#8217;m going to assume you already have a Rackspace Cloud account. (If you don&#8217;t, I&#8217;ll leave it to you to rectify the situation.)</p><p><strong><span
style="text-decoration: underline;">Create a Server</span></strong></p><p>Follow these steps to create a Rackspace Cloud Server:</p><ol><li>Log in to the control panel at <a
href="http://manage.rackspacecloud.com/" target="_blank">manage.rackspacecloud.com</a>.</li><li>Click on <strong>Hosting</strong> in the left nav bar, then <strong>Cloud Servers</strong>.</li><li>Click <strong>Add New Server</strong>.</li><li>Now, it&#8217;s time to pick how much RAM and storage space you want (and how much you want to pay per hour). The default, 256 MB RAM and 10 GB storage at $0.015 an hour, is fine for our purposes.</li><li>Scroll down and give your server a name, like, oh, I don&#8217;t know, &#8220;<strong>Fred</strong>&#8221; or &#8220;<strong>Rails-Test</strong>&#8221; or something.</li><li>Next, choose your favorite flavor of <span
style="text-decoration: line-through;">ice cream</span> operating system. I like the Ubuntu LTS (Long-Term Support) releases. Yum. No, wait, I mean apt-get. <img
src='http://wildblueether.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /></li><li>Finally, click <strong>Add Cloud Server</strong>.</li></ol><p>While it is building your server according to your specifications, the control panel will give you an IP address and a root password. This information will also be emailed to the primary contact email address associated with your account. Be sure to keep it in a safe place.</p><p>Once your server is ready, you can SSH into it. In a Terminal, issue the following command:</p><pre class="brush: plain; title: ; notranslate">ssh root@&lt;your_server_IP_address&gt;</pre><p>Enter your root password when prompted.</p><p><strong><span
style="text-decoration: underline;">Bootstrap That Baby</span></strong></p><p>Marc Chung (formerly of OpenRain, now of redPear) has published, as a GitHub repo, a collection of handy-dandy shell scripts to aid us in bootstrapping a Rails server. Go <a
href="http://github.com/openrain/bootstrap/tree/master/slicehost/" target="_blank">here</a> and start to follow the instructions in the README. Update and upgrade Ubuntu, install Git, and clone the Git repo to get the scripts.</p><p><strong>Set Up Password-less Authentication</strong></p><p>Before we start running scripts, we ought to make it so that we can connect to our remote server from our local Mac without having to type in a password, while at the same time ensuring that no one besides us can connect in this way. (This is necessary for the deployment process to work, as we&#8217;ll see in our next episode.) We&#8217;ll achieve this by adding the public key we generated <a
href="http://www.wildblueether.com/2009/12/31/on-the-rails-set-up-git-repos-locally-and-on-github/" target="_blank">earlier</a> on our Mac to an &#8220;authorized_keys&#8221; file on the remote server. (<a
href="http://www.hostingrails.com/HowTo-SSH-SCP-without-a-password" target="_blank">reference</a>)</p><ol><li>On the Mac, run &#8220;cat ~/.ssh/id_rsa.pub&#8221; and copy the result to the clipboard.</li><li>On the server, run &#8220;pico ~/bootstrap/config/root_authorized_keys&#8221;. Paste the key into this file and save it (Ctrl-O).</li><li>On the server, run &#8220;pico ~/bootstrap/config/default_authorized_keys&#8221;. Paste the key into this file and save it (Ctrl-O).</li></ol><p><strong>Edit/Run Scripts</strong></p><p>On the server, from the ~/bootstrap/slicehost directory, we are going to be running these scripts in order:</p><pre class="brush: plain; title: ; notranslate">00-core.sh
05-ruby.sh
10-misc.sh
15-postgresql.sh
25-apache.sh
36-passenger.sh
40-rails-apps.sh</pre><p>You can run the core, ruby, and misc scripts as written.</p><p>Before running the postgresql script, you should edit it to customize one of the config options. Namely, edit the &#8220;add addresses&#8221; block in that file. Change the IP addresses to match the machines from which you&#8217;ll be remotely connecting to your PostgreSQL database server, if any. If there are none, you can delete this block.</p><p>When running the postgresql script, you have to provide it a password for your database&#8217;s admin user. We&#8217;ll set a temporary environment variable for this, at the same time we run the script, as shown in Marc&#8217;s instructions:</p><pre class="brush: plain; title: ; notranslate">PGPASSWORD='clark_kent_is_superman' sh ./15-postgresql.sh</pre><p>Be sure to replace the value given for the password with your own value.</p><p>We&#8217;ll then run a separate block of script, similar to what&#8217;s shown in Marc&#8217;s instructions, to create a normal user for our database, and then the database itself:</p><pre class="brush: plain; title: ; notranslate">cat &gt; /tmp/postgres.sql &lt;&lt;EOF
CREATE ROLE railstest
  LOGIN ENCRYPTED PASSWORD 'batman_is_bruce_wayne'
  INHERIT CREATEDB;
CREATE DATABASE railstest
  OWNER = railstest;
EOF
sudo su postgres -c psql template1 &lt; /tmp/postgres.sql
rm /tmp/postgres.sql</pre><p>In the above block of script, remember to replace the values given with your own values for:</p><ol><li>your normal database user&#8217;s username (in our case, <strong>railstest</strong>)</li><li>your normal database user&#8217;s password (we&#8217;ll have to add this to our app in <strong>railstest/config/database.yml</strong> too)</li><li>the name of the database you want to create for your app (in our case, <strong>railstest_production</strong>)</li></ol><p>The apache script can be run as written.</p><p>The passenger script requires that one environment variable be set: the public hostname of your server (example: <strong>rails.example.com</strong>):</p><pre class="brush: plain; title: ; notranslate">SERVERNAME=rails.example.com sh ./36-passenger.sh</pre><p>After running the passenger script, let&#8217;s edit one of our Apache config files:</p><pre class="brush: plain; title: ; notranslate">pico /etc/apache2/sites-available/default</pre><p>Along with the addition and modification of a couple other options, we&#8217;re going to change the DocumentRoot to the directory where our app is going to live. Edit the VirtualHost block of the file to look like this:</p><pre class="brush: plain; title: ; notranslate">
&lt;VirtualHost *&gt;
    ServerAdmin youremail@yourdomain.com
    ServerName rails.example.com
    DocumentRoot /var/local/railstest/current/public
    RailsBaseURI /
    &lt;Directory /&gt;
        Options FollowSymLinks
        AllowOverride None
    &lt;/Directory&gt;
    &lt;Directory /var/local/railstest/current/public&gt;
        Options Indexes FollowSymLinks -MultiViews
        AllowOverride all
        Order allow,deny
        allow from all
    &lt;/Directory&gt;
...
</pre><p>Save the file with Ctrl-O. Exit with Ctrl-X, and then run:</p><pre class="brush: plain; title: ; notranslate">apache2ctl -k graceful</pre><p>to restart Apache.</p><p>Finally, you can run the rails-apps script as written.</p><p><strong>Post-Scripts</strong></p><p>After we&#8217;ve finished running the scripts, we want to make it so that the server can connect to GitHub and access our app&#8217;s code repo during the deployment process.</p><p>Let&#8217;s generate an SSH keypair on the remote server, but as the &#8220;app&#8221; user instead of root, since that&#8217;s the one that we&#8217;ll be running the deployment process as:</p><pre class="brush: plain; title: ; notranslate">sudo su app -c &quot;ssh-keygen -t rsa&quot;</pre><p>As we did <a
href="http://www.wildblueether.com/2009/12/31/on-the-rails-set-up-git-repos-locally-and-on-github/" target="_blank">earlier</a> with the keys generated on our Mac, we&#8217;ll paste the public key into our GitHub config:</p><ol><li>Run &#8220;cat /home/app/.ssh/id_rsa.pub&#8221; on the server and copy the result to the clipboard.</li><li>On GitHub, go to your repo&#8217;s home page and click the &#8220;Admin&#8221; button.</li><li>Under the &#8220;Deploy Keys&#8221; section, click &#8220;Add another deploy key&#8221;.</li><li>Give the deploy key a title, like &#8220;Production App Server&#8221; or something.</li><li>Paste the contents of the clipboard into the &#8220;Key&#8221; textarea.</li><li>Click &#8220;Add Key&#8221;.</li></ol><p>We&#8217;re done bootstrapping! Our Rackspace Cloud Server is now prepped and ready to run our app upon its arrival. Be sure to type &#8220;exit&#8221; to log out and close your SSH connection.</p><p><strong><span
style="text-decoration: underline;">One More Thing</span></strong></p><p>Before we call it quits for this episode, let&#8217;s go back to our Mac for a second and make sure we add the normal database user&#8217;s password to our config file. In Terminal, from our home directory, do the following:</p><pre class="brush: plain; title: ; notranslate">cd workspace/railstest
pico config/database.yml</pre><p>Go down to the empty &#8220;password:&#8221; line in the &#8220;production&#8221; section at the end of the file and add the password you specified above in the separate postgres.sql script (the one which created the normal user and the database). Type Ctrl-O to save the file.</p><p><strong><span
style="text-decoration: underline;">Next Time</span></strong></p><p>In our next episode, we&#8217;ll install Capistrano and deploy our app to this baby! See you then!</p> ]]></content:encoded> <wfw:commentRss>http://wildblueether.com/2010/01/08/on-the-rails-bootstrap-a-rackspace-cloud-server/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>On the Rails: Set Up Git Repos Locally and On GitHub</title><link>http://wildblueether.com/2009/12/31/on-the-rails-set-up-git-repos-locally-and-on-github/</link> <comments>http://wildblueether.com/2009/12/31/on-the-rails-set-up-git-repos-locally-and-on-github/#comments</comments> <pubDate>Fri, 01 Jan 2010 06:07:06 +0000</pubDate> <dc:creator>Jeremy Merrill</dc:creator> <category><![CDATA[On the Ground]]></category><guid
isPermaLink="false">http://www.wildblueether.com/?p=253</guid> <description><![CDATA[GitHub Let&#8217;s prepare GitHub for our code&#8217;s arrival. Go to github.com. If you don&#8217;t already have an account, click on &#8220;Pricing and Signup&#8221; at the top and get a free one. Log in to your account. Click &#8220;New Repository&#8221; in the upper right of the &#8220;Your Repositories&#8221; box. Give your repo the name &#8220;railstest&#8221;, along [...]]]></description> <content:encoded><![CDATA[<div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwildblueether.com%2F2009%2F12%2F31%2Fon-the-rails-set-up-git-repos-locally-and-on-github%2F"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwildblueether.com%2F2009%2F12%2F31%2Fon-the-rails-set-up-git-repos-locally-and-on-github%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br
/> </a></div><p><strong><span
style="text-decoration: underline;">GitHub</span></strong></p><p>Let&#8217;s prepare GitHub for our code&#8217;s arrival.</p><ol><li>Go to <a
href="http://github.com/" target="_blank">github.com</a>.</li><li>If you don&#8217;t already have an account, click on &#8220;Pricing and Signup&#8221; at the top and get a free one.</li><li>Log in to your account.</li><li>Click &#8220;New Repository&#8221; in the upper right of the &#8220;Your Repositories&#8221; box.</li><li>Give your repo the name &#8220;railstest&#8221;, along with an appropriate description and URL if you know where your project will live in production (i.e. its hostname).</li><li>Click &#8220;Create Repository&#8221;.</li></ol><p>Next, we need to generate an SSH keypair on our local machine, and add the public key to our GitHub account so our local machine can access the GitHub repo we just created. In a Terminal, issue the following command:</p><pre class="brush: plain; title: ; notranslate">ssh-keygen -C &quot;youremail@yourdomain.com&quot; -t rsa</pre><p>Accept the defaults, and don&#8217;t supply a passphrase unless you want to. Now, issue the following command to display the public key:</p><pre class="brush: plain; title: ; notranslate">cat ~/.ssh/id_rsa.pub</pre><p>Copy the contents of ~/.ssh/id_rsa.pub to the clipboard, and follow these steps:</p><ol><li>On GitHub, click &#8220;Account Settings&#8221; in the upper right of the page.</li><li>Click &#8220;SSH Public Keys&#8221; in the second row of tabs.</li><li>Click &#8220;Add another public key&#8221;.</li><li>Give the key a title, like &#8220;Jeremy&#8217;s Key on MacBook&#8221;.</li><li>Paste the contents of ~/.ssh/id_rsa.pub from the clipboard into the &#8220;Key&#8221; textarea.</li><li>Click the &#8220;Add key&#8221; button.</li></ol><p>Now, we&#8217;re ready to set things up locally.</p><p><strong><span
style="text-decoration: underline;">Locally</span></strong></p><p>With a few additions and modifications, we&#8217;ll follow the instructions you saw after creating the repo. In Terminal, from your home directory, issue the following commands in order:</p><pre class="brush: plain; title: ; notranslate">git config --global user.name &quot;Your Name&quot;
git config --global user.email youremail@yourdomain.com
cd workspace/railstest
git init
git add .
git commit -m 'Initial import'
git remote add origin git@github.com:your_github_username/railstest.git
git push origin master</pre><p>Now, let&#8217;s go back to our repo on GitHub and make sure our code made it there OK. That&#8217;s it!</p><p><strong><span
style="text-decoration: underline;">Next time</span>:</strong> We&#8217;ll create a Cloud Server on the Rackspace Cloud, set it up to host our app, and use Capistrano to deploy our code from GitHub to our server. See you then!</p> ]]></content:encoded> <wfw:commentRss>http://wildblueether.com/2009/12/31/on-the-rails-set-up-git-repos-locally-and-on-github/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>On the Rails: Install Apache 2 and Passenger Locally</title><link>http://wildblueether.com/2009/12/31/on-the-rails-install-apache-2-and-passenger-locally/</link> <comments>http://wildblueether.com/2009/12/31/on-the-rails-install-apache-2-and-passenger-locally/#comments</comments> <pubDate>Thu, 31 Dec 2009 20:50:12 +0000</pubDate> <dc:creator>Jeremy Merrill</dc:creator> <category><![CDATA[On the Ground]]></category><guid
isPermaLink="false">http://www.wildblueether.com/?p=228</guid> <description><![CDATA[For the sake of matching our production environment as closely as possible, let&#8217;s take a few minutes to install the Apache 2 web server and Phusion Passenger application layer locally. First, Apache 2: Next, Passenger: Now, let&#8217;s build and install the Passenger extension module for Apache 2. This part was a little tricky for me, [...]]]></description> <content:encoded><![CDATA[<div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwildblueether.com%2F2009%2F12%2F31%2Fon-the-rails-install-apache-2-and-passenger-locally%2F"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwildblueether.com%2F2009%2F12%2F31%2Fon-the-rails-install-apache-2-and-passenger-locally%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br
/> </a></div><p>For the sake of matching our production environment as closely as possible, let&#8217;s take a few minutes to install the Apache 2 web server and Phusion Passenger application layer locally. First, Apache 2:</p><pre class="brush: plain; title: ; notranslate">sudo port install apache2</pre><p>Next, Passenger:</p><pre class="brush: plain; title: ; notranslate">sudo gem install passenger</pre><p>Now, let&#8217;s build and install the Passenger extension module for Apache 2. This part was a little tricky for me, due to the fact that we&#8217;ve installed another Apache 2 via MacPorts. We want the Passenger module build process to find the MacPorts one, and not the one that came with Snow Leopard. I found and followed a <a
href="http://9thport.net/archives/340" target="_blank">couple</a> <a
href="http://brianketelsen.blogspot.com/2008/04/phusion-passenger-simple-rails.html" target="_blank">other</a> instructional blog posts on this, but I ended up doing something other than what they did to get it to work.</p><p>First, let&#8217;s add a line to the end of our ~/.profile file. (Type &#8220;pico ~/.profile&#8221; to edit it.)</p><pre class="brush: plain; title: ; notranslate">export PATH=&quot;/opt/local/apache2/bin:$PATH&quot;</pre><p>Next, run the following command:</p><pre class="brush: plain; title: ; notranslate">source ~/.profile</pre><p>Now, we can build the module:</p><pre class="brush: plain; title: ; notranslate">sudo passenger-install-apache2-module</pre><p>After that builds and installs the module, let&#8217;s edit our Apache 2 config file. (Type &#8220;sudo pico /opt/local/apache2/conf/httpd.conf&#8221; to edit it.)</p><p>First, let&#8217;s type Ctrl-W and enter &#8220;80&#8243; to search for the string &#8220;80&#8243;. 80 is the default port Apache listens on. But that port is already bound to the Snow Leopard Apache. Let&#8217;s change the port our MacPorts Apache will listen on to 3000. Comment out this line (add a &#8220;#&#8221; character in front):</p><pre class="brush: plain; title: ; notranslate">Listen 80</pre><p>And add the following line right underneath it:</p><pre class="brush: plain; title: ; notranslate">Listen 3000</pre><p>Next, let&#8217;s add the following to the end of the file:</p><pre class="brush: plain; title: ; notranslate">
LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.8/ext/apache2/mod_passenger.so
PassengerRoot /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.8
PassengerRuby /opt/local/bin/ruby
PassengerDefaultUser your_username

&lt;VirtualHost *:3000&gt;
   ServerName localhost
   DocumentRoot /Users/your_username/workspace/railstest/public
   RailsBaseURI /
   RailsEnv development
   &lt;Directory /Users/your_username/workspace/railstest/public&gt;
      AllowOverride all
      Options Indexes FollowSymLinks -MultiViews
      Order allow,deny
      Allow from all
   &lt;/Directory&gt;
&lt;/VirtualHost&gt;
</pre><p>The Phusion Passenger <a
href="http://www.modrails.com/documentation/Users%20guide%20Apache.html" target="_blank">users guide for Apache</a> was helpful on this step. Be sure to replace &#8220;your_username&#8221; and &#8220;workspace&#8221; above with your username and the name of the directory containing your Rails projects.</p><p>Now, let&#8217;s start Apache:</p><pre class="brush: plain; title: ; notranslate">sudo apachectl start</pre><p>And, in a separate Terminal, start PostgreSQL if it&#8217;s not already running:</p><pre class="brush: plain; title: ; notranslate">sudo su postgres -c '/opt/local/lib/postgresql84/bin/postgres -D /opt/local/var/db/postgresql84/railstest'</pre><p>Browse to:</p><pre class="brush: plain; title: ; notranslate">http://localhost:3000/books</pre><p>and voila! Our CRUD app from last time is now running on Apache with Phusion Passenger instead of WEBrick!</p><p><strong><span
style="text-decoration: underline;">Next up</span>:</strong> Git and GitHub stuff.</p> ]]></content:encoded> <wfw:commentRss>http://wildblueether.com/2009/12/31/on-the-rails-install-apache-2-and-passenger-locally/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>On the Rails: Create a Simple CRUD App, Set Up a Database</title><link>http://wildblueether.com/2009/12/29/on-the-rails-create-a-simple-crud-app-set-up-a-database/</link> <comments>http://wildblueether.com/2009/12/29/on-the-rails-create-a-simple-crud-app-set-up-a-database/#comments</comments> <pubDate>Wed, 30 Dec 2009 06:41:25 +0000</pubDate> <dc:creator>Jeremy Merrill</dc:creator> <category><![CDATA[On the Ground]]></category><guid
isPermaLink="false">http://www.wildblueether.com/?p=200</guid> <description><![CDATA[Once you have everything installed, it&#8217;s actually pretty easy to create a basic application in Rails that can perform the four basic CRUD operations &#8212; Create, Read, Update, Delete &#8212; on a set of data. Before we create the app, though, let&#8217;s briefly describe what our data is going to look like. Let&#8217;s say we [...]]]></description> <content:encoded><![CDATA[<div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwildblueether.com%2F2009%2F12%2F29%2Fon-the-rails-create-a-simple-crud-app-set-up-a-database%2F"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwildblueether.com%2F2009%2F12%2F29%2Fon-the-rails-create-a-simple-crud-app-set-up-a-database%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br
/> </a></div><p>Once you <a
href="http://www.wildblueether.com/2009/12/15/setting-up-rails-and-postgresql-on-snow-leopard/">have everything installed</a>, it&#8217;s actually pretty easy to create a basic application in Rails that can perform the four basic CRUD operations &#8212; Create, Read, Update, Delete &#8212; on a set of data.</p><p>Before we create the app, though, let&#8217;s briefly describe what our data is going to look like. Let&#8217;s say we want to store some basic information about all of the books we have in our possession. Most books have, among other things, a title, an author, a publishing company, a copyright year, and an ISBN number (a unique identifier). If our database table is going to be composed of books, then each record in that table is going to have each one of the above attributes, stored as strings of text.</p><p><strong><span
style="text-decoration: underline;">Create CRUD App</span></strong></p><p>So, let&#8217;s first create our initial, empty skeleton of a Rails app.  From your home directory, or whatever directory you want to store your Rails projects in, issue the following command:</p><pre class="brush: plain; title: ; notranslate">rails railstest -d postgresql</pre><p>This will create a folder named &#8220;railstest&#8221; and populate it with all of the wonderful goodies that Rails provides as a foundation for writing a web-based application that follows the Model-View-Controller architectural pattern. The &#8220;-d postgresql&#8221; part pre-configures the app to use the relational database system we have chosen, PostgreSQL. (If you wanted to use MySQL or something else, you could just as easily specify a command-line argument for whatever you&#8217;ve chosen instead. Type &#8220;rails &#8211;help&#8221; to see all the options.)</p><p>Now, we&#8217;re going to take our foundation and build a CRUD app on top of it. But we&#8217;re not going to type a single line of Ruby code. We&#8217;re going to make use of scaffolding. (Later, we&#8217;ll want to avoid scaffolding like the plague, and build our apps by actually writing our own Ruby code, but we&#8217;re trying to get up and running ASAP, so we&#8217;ll take the easy way for now.)</p><p>Issue the following commands from the directory containing your Rails project(s):</p><pre class="brush: plain; title: ; notranslate">cd railstest
./script/generate scaffold book title:string author:string publisher:string copyright_year:string isbn:string</pre><p>This will create some code files &#8212; models, views, and controllers &#8212; and a database migration, which describes how to set up our database schema. We&#8217;ll be invoking rake (a build program for Ruby) a little later to do just that.</p><p><strong><span
style="text-decoration: underline;">Set Up Database</span></strong></p><p>Before we do that, though, we should create a database cluster, launch the database server, create a new database user, and finally create the database. (You may have taken note of some instructions that appeared in your Terminal after you installed PostgreSQL. If you did, some of the commands in this step should look familiar.)</p><p>First, we need to create and initialize the data directory, or database cluster. Issue the following three commands in order:</p><pre class="brush: plain; title: ; notranslate">sudo mkdir -p /opt/local/var/db/postgresql84/railstest
sudo chown postgres:postgres /opt/local/var/db/postgresql84/railstest
sudo su postgres -c '/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql84/railstest'</pre><p>Next, launch the database server. Open a new Terminal tab or window, and then issue the following command:</p><pre class="brush: plain; title: ; notranslate">sudo su postgres -c '/opt/local/lib/postgresql84/bin/postgres -D /opt/local/var/db/postgresql84/railstest'</pre><p>Next, create a new database user (or role):</p><pre class="brush: plain; title: ; notranslate">sudo su postgres -c '/opt/local/lib/postgresql84/bin/createuser -S -d -R railstest'</pre><p>Finally, create the development database:</p><pre class="brush: plain; title: ; notranslate">sudo su postgres -c '/opt/local/lib/postgresql84/bin/createdb -O railstest railstest_development'</pre><p>Now, let&#8217;s run rake and create our schema:</p><pre class="brush: plain; title: ; notranslate">rake db:migrate</pre><p><strong><span
style="text-decoration: underline;">Just Push Play</span></strong></p><p>We&#8217;re almost there! Time to start up our web server and Ruby application layer. At the moment, all we have is WEBrick, which comes with Ruby. (<strong><span
style="text-decoration: underline;">Note</span></strong>: WEBrick is a quick and dirty web server solution that will run our simple app and get us to the end of this part of the tutorial, but it should not be used for anything more complicated, and certainly not in a production environment.) Run the following command in a new Terminal:</p><pre class="brush: plain; title: ; notranslate">./script/server</pre><p>Now, open your web browser and go to:</p><pre class="brush: plain; title: ; notranslate">http://localhost:3000</pre><p>You should see a Rails welcome screen. Next, go to:</p><pre class="brush: plain; title: ; notranslate">http://localhost:3000/books</pre><p>You should see our CRUD app! You should now be able to Create, Read (or Show), Update (or Edit) and Delete (or Destroy) books. The data is stored in our PostgreSQL database instance we created above.</p><p><strong><span
style="text-decoration: underline;">Next Episode</span></strong></p><p>Next time, we&#8217;ll put the code under version control locally using git, set up a remote repository on GitHub, and then push our code to that remote location. See you then!</p> ]]></content:encoded> <wfw:commentRss>http://wildblueether.com/2009/12/29/on-the-rails-create-a-simple-crud-app-set-up-a-database/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Setting Up Rails and PostgreSQL on Snow Leopard</title><link>http://wildblueether.com/2009/12/15/setting-up-rails-and-postgresql-on-snow-leopard/</link> <comments>http://wildblueether.com/2009/12/15/setting-up-rails-and-postgresql-on-snow-leopard/#comments</comments> <pubDate>Wed, 16 Dec 2009 05:42:48 +0000</pubDate> <dc:creator>Jeremy Merrill</dc:creator> <category><![CDATA[On the Ground]]></category><guid
isPermaLink="false">http://www.wildblueether.com/?p=183</guid> <description><![CDATA[Hello again. This post will go over how to set up the Ruby language, the Ruby on Rails web framework, and the PostgreSQL relational database server on an Intel Mac running Mac OS X 10.6 (Snow Leopard). Note: As the Perl folks say, there&#8217;s more than one way to do it. This is only one [...]]]></description> <content:encoded><![CDATA[<div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwildblueether.com%2F2009%2F12%2F15%2Fsetting-up-rails-and-postgresql-on-snow-leopard%2F"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwildblueether.com%2F2009%2F12%2F15%2Fsetting-up-rails-and-postgresql-on-snow-leopard%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br
/> </a></div><p>Hello again. This post will go over how to set up the Ruby language, the Ruby on Rails web framework, and the PostgreSQL relational database server on an Intel Mac running Mac OS X 10.6 (Snow Leopard).</p><p><span
style="text-decoration: underline;">Note</span>: As the Perl folks say, <a
href="http://en.wikipedia.org/wiki/There's_more_than_one_way_to_do_it" target="_blank">there&#8217;s more than one way to do it</a>. This is only one of many possible configurations and ways to set things up. I&#8217;m writing this post (and the next two or three) for my future self and anyone else who might want to get up and running with Rails this way.</p><p>In the next few posts, we will: create a simple database-driven CRUD web application in Rails; set up a source repository on GitHub and push our code there; create a server on the Rackspace Cloud, set it up for production use, and finally deploy our app from GitHub to that server.</p><p>This post is really an adaptation of <a
href="http://jaredonline.posterous.com/full-stack-ruby-on-rails-development-for-snow" target="_blank">a nice guide written by Jared McFarland</a>. His setup includes MySQL rather than Postgres, and so my post will only modify and elaborate on his where appropriate.</p><p>Let&#8217;s begin.</p><p><strong><span
style="text-decoration: underline;">MacPorts</span></strong></p><p>The first thing we want to get is MacPorts, a system by which we can easily get the latest, most widely-used versions of Ruby, RubyGems (a Ruby software packaging system), Ruby on Rails, and PostgreSQL. (Snow Leopard does come with versions of Ruby, Gems and Rails, but things move fast, and they were already outdated when Snow Leopard was released.)</p><p>Go <a
href="http://www.macports.org/install.php" target="_blank">here</a> and get the latest DMG disk image for Snow Leopard (1.8.1 at this writing). Install the PKG. (<span
style="text-decoration: underline;">Note</span>: MacPorts will put itself and everything else you install via MacPorts in the <strong>/opt</strong> folder on your primary hard disk, so you&#8217;ll know where everything is in case you want to get rid of it later.)</p><p><strong><span
style="text-decoration: underline;">Ruby</span></strong></p><p><em>[</em><strong><em>Update</em></strong><em>, 12/21/2009, 4:30 p.m. MST: </em><a
href="http://blog.marcchung.com/" target="_blank"><em>Marc Chung</em></a><em> tells me that a better way to install Ruby than that described in this section is via </em><a
href="http://rvm.beginrescueend.com/" target="_blank"><em>rvm</em></a><em> (Ruby Version Manager), which allows you to have multiple Rubies installed and switch between them. More details forthcoming.]</em></p><p>In Terminal, do:</p><pre>sudo port install ruby</pre><p>and enter your user account password if/when prompted. This will install the latest Ruby 1.8, which at this writing is 1.8.7, patchlevel 174, dated June 12, 2009.</p><p>When it&#8217;s done, do:</p><pre>which ruby</pre><p>and you should see:</p><pre>/opt/local/bin/ruby</pre><p>Now, do:</p><pre>ruby -v</pre><p>and you should see:</p><pre>ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]</pre><p><strong><span
style="text-decoration: underline;">RubyGems</span></strong></p><pre>sudo port install rb-rubygems</pre><p>Latest RubyGems on MacPorts is 1.3.4. (1.3.5 is the actual latest and is coming to MacPorts <strong><a
href="http://en.wikipedia.org/wiki/Real_soon_now" target="_blank">Real Soon Now</a></strong>).</p><p><strong><span
style="text-decoration: underline;">SVN and Git</span></strong></p><pre>sudo port install subversion</pre><pre>sudo port install git-core +svn</pre><p>If you don&#8217;t have any existing Subversion repositories, you can ignore the subversion line and omit &#8220;+svn&#8221; from the git-core line. If you&#8217;re starting from scratch, you only need Git. Latest Git on MacPorts is 1.6.5.3 (actual latest 1.6.5.6).</p><p><strong><span
style="text-decoration: underline;">PostgreSQL</span></strong></p><pre>sudo port install postgresql84-server</pre><p>Latest PostgreSQL is 8.4.2, and it&#8217;s on MacPorts.</p><p>[<strong>Update</strong>, 12/24/2009, 12:30 am MST: Add the following line to the end of your ~/.profile file:</p><pre>export PATH="/opt/local/lib/postgresql84/bin:$PATH"</pre><p>Then issue the following command from the prompt:</p><pre>source ~/.profile</pre><p>The PostgreSQL binaries need to be in your PATH; if they aren't, the next step will fail.]</p><p>That&#8217;s all for the MacPorts stuff. Now for some Ruby Gems.</p><p><strong><span
style="text-decoration: underline;">PostgreSQL Ruby Adapter</span></strong></p><pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">sudo gem install pg</pre><p>Latest PostgreSQL Ruby Adapter gem (pg, a.k.a. ruby-pg) is 0.8.0.</p><p><strong><span
style="text-decoration: underline;">Rails</span></strong></p><pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">sudo gem install rails</pre><p>Latest Rails is 2.3.5. This includes eight gems &#8212; actionmailer, actionpack, activerecord, activeresource, activesupport, and rails (all 2.3.5); rack (1.0.1); and rake (0.8.7).</p><p>You now have all the software you need to start developing web applications using Ruby on Rails on your Snow Leopard Mac!</p><p>Be sure to tune in next time, for another exciting episode of <em>Jeremy&#8217;s Wild and Crazy Adventures on </em>(off?)<em> the Rails</em>, when we&#8217;ll discover how to create a basic CRUD app in Rails<em> without writing a single line of Ruby code!</em> (Before long, we&#8217;ll want to develop apps by actually writing some Ruby code, but more on that later.) We&#8217;ll also set up Git repositories in which to store and track our code revisions, both locally and on GitHub. See you then!</p> ]]></content:encoded> <wfw:commentRss>http://wildblueether.com/2009/12/15/setting-up-rails-and-postgresql-on-snow-leopard/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Did Apple &quot;Push&quot; Safari 4 Out to Millions of Users? Not Really.</title><link>http://wildblueether.com/2009/06/13/did-apple-push-safari-4-out-to-millions-of-users-not-really/</link> <comments>http://wildblueether.com/2009/06/13/did-apple-push-safari-4-out-to-millions-of-users-not-really/#comments</comments> <pubDate>Sat, 13 Jun 2009 08:24:19 +0000</pubDate> <dc:creator>Jeremy Merrill</dc:creator> <category><![CDATA[On the Ground]]></category><guid
isPermaLink="false">http://www.wildblueether.com/?p=137</guid> <description><![CDATA[Paul Thurrott, in a post featured prominently on Techmeme, wrote Friday that Apple is &#8220;making lemonade&#8221; in claiming that its new web browser, Safari 4, has been downloaded more than 11 million times.  Paul quotes approvingly from a piece by PC World&#8217;s Robert Strohmeyer which was cross-posted to Macworld: As someone with three Macs at [...]]]></description> <content:encoded><![CDATA[<div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwildblueether.com%2F2009%2F06%2F13%2Fdid-apple-push-safari-4-out-to-millions-of-users-not-really%2F"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwildblueether.com%2F2009%2F06%2F13%2Fdid-apple-push-safari-4-out-to-millions-of-users-not-really%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br
/> </a></div><p>Paul Thurrott, in a post <a
href="http://www.techmeme.com/090612/p78#a090612p78" target="_blank">featured</a> prominently on Techmeme, <a
href="http://community.winsupersite.com/blogs/paul/archive/2009/06/12/11-million-safari-downloads-um-sort-of.aspx" target="_blank">wrote</a> Friday that Apple is &#8220;making lemonade&#8221; in <a
href="http://www.apple.com/pr/library/2009/06/12safari.html" target="_blank">claiming</a> that its new web browser, Safari 4, has been downloaded more than 11 million times.  Paul quotes approvingly from a <a
href="http://www.macworld.com/article/141140/2009/06/safari4downloads.html">piece</a> by PC World&#8217;s Robert Strohmeyer which was cross-posted to Macworld:</p><blockquote><p>As someone with three Macs at home, I couldn&#8217;t help but notice that <strong>Apple pushed Safari 4 out as an automatic update to all of its users this week</strong>. Yesterday, all three of the Macs in my household received the update, and we don&#8217;t even use Safari.</p><p>An informal poll of my friends and colleagues reveals a whole lot of the same. Got the update dialog, downloaded and installed it, don&#8217;t intend to use it.</p><p><strong>What is at issue is the ridiculously thin claim that the latest Safari is a wild success on the basis that Apple basically pushed it out to everyone it possibly could, whether they wanted it or not.</strong></p></blockquote><p>(Emphasis Paul&#8217;s.)</p><p>What I take issue with is Robert&#8217;s equally misleading title (&#8220;Safari 4 download stat is pure hype&#8221;) and use of the phrase &#8220;<strong>pushed it out</strong>&#8220;.  I suppose it depends on how you define &#8220;<strong>push</strong>&#8220;, but to me, this reflects a lack of understanding of how Apple Software Update works.<br
/> <span
id="more-137"></span><br
/> Unlike Microsoft&#8217;s Automatic Updates, for which the recommended and default behavior is to automatically check for, download, and install updates at a given time of day (what I consider &#8220;<strong>push</strong>&#8220;), Apple Software Update does not have the ability to automatically download or install anything:</p><p><a
href="http://www.wildblueether.com/wp-content/uploads/2009/06/WinAutomaticUpdates1.jpg"><img
class="alignnone size-full wp-image-146" title="WinAutomaticUpdates" src="http://www.wildblueether.com/wp-content/uploads/2009/06/WinAutomaticUpdates1.jpg" border="0" alt="WinAutomaticUpdates" width="420" height="464" /></a></p><p><a
href="http://www.wildblueether.com/wp-content/uploads/2009/06/AppleSoftwareUpdatePrefs.jpg"><img
class="alignnone size-full wp-image-141" title="AppleSoftwareUpdatePrefs" src="http://www.wildblueether.com/wp-content/uploads/2009/06/AppleSoftwareUpdatePrefs.jpg" border="0" alt="AppleSoftwareUpdatePrefs" width="442" height="293" /></a></p><p>Here&#8217;s what Apple Software Update looks like when it pops up, first on a Windows XP machine without Safari installed:</p><p><a
href="http://www.wildblueether.com/wp-content/uploads/2009/06/AppleSoftwareUpdate-SafariNotInstalled.jpg"><img
class="alignnone size-full wp-image-143" title="AppleSoftwareUpdate-SafariNotInstalled" src="http://www.wildblueether.com/wp-content/uploads/2009/06/AppleSoftwareUpdate-SafariNotInstalled.jpg" border="0" alt="AppleSoftwareUpdate-SafariNotInstalled" width="426" height="556" /></a></p><p>With Safari 3.2.3 installed:</p><p><a
href="http://www.wildblueether.com/wp-content/uploads/2009/06/AppleSoftwareUpdate-Safari323Installed.jpg"><img
class="alignnone size-full wp-image-142" title="AppleSoftwareUpdate-Safari323Installed" src="http://www.wildblueether.com/wp-content/uploads/2009/06/AppleSoftwareUpdate-Safari323Installed.jpg" border="0" alt="AppleSoftwareUpdate-Safari323Installed" width="426" height="556" /></a></p><p>Without Safari installed, Safari 4 appears in the lower pane (New Software), <strong>not selected</strong>.  With Safari 3 (or 4 beta) installed, Safari 4 appears in the upper pane (Updates), <strong>already selected</strong>, meaning the user must un-check the box if they choose not to install Safari 4.</p><p>Is Strohmeyer suggesting that most Mac users (including himself, evidently) are too lazy and/or ignorant to un-check the box for Safari in Apple Software Update, and are therefore (in some cases, unknowingly) downloading and installing Safari 4, without actually wanting it?</p><p>Is Thurrott suggesting that most Windows users (including himself, evidently) who had previously <strong>made a choice</strong> to download and install Safari (which is not bundled with Windows) are similarly too lazy and/or ignorant?</p><p>Apple is not &#8220;pushing&#8221; Safari 4 on anyone.  And I doubt that the laziness or ignorance of users accounts for a significant fraction of the Safari 4 downloads claimed by Apple.</p> ]]></content:encoded> <wfw:commentRss>http://wildblueether.com/2009/06/13/did-apple-push-safari-4-out-to-millions-of-users-not-really/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Cloud Computing != Grid Computing?</title><link>http://wildblueether.com/2009/01/31/cloud-computing-grid-computing/</link> <comments>http://wildblueether.com/2009/01/31/cloud-computing-grid-computing/#comments</comments> <pubDate>Sat, 31 Jan 2009 22:08:26 +0000</pubDate> <dc:creator>Jeremy Merrill</dc:creator> <category><![CDATA[On the Ground]]></category><guid
isPermaLink="false">http://www.wildblueether.com/?p=120</guid> <description><![CDATA[Following up to a previous post, I came across a July 2008 article by Thorsten von Eicken, CTO and founder of RightScale, which provides a front-end for managing Amazon Web Services (Amazon&#8217;s cloud computing offerings): Grid computing has been used in environments where users make few but large allocation requests. &#8230; [O]nly a few of [...]]]></description> <content:encoded><![CDATA[<div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwildblueether.com%2F2009%2F01%2F31%2Fcloud-computing-grid-computing%2F"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwildblueether.com%2F2009%2F01%2F31%2Fcloud-computing-grid-computing%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br
/> </a></div><p>Following up to a <a
href="http://www.wildblueether.com/2008/11/06/is-cloud-computing-what-sun-meant/" target="_blank">previous post</a>, I came across a <a
href="http://blog.rightscale.com/2008/07/07/cloud-computing-vs-grid-computing/" target="_blank">July 2008 article</a> by Thorsten von Eicken, CTO and founder of <a
href="http://www.rightscale.com/" target="_blank">RightScale</a>, which provides a front-end for managing <a
href="http://aws.amazon.com/" target="_blank">Amazon Web Services</a> (Amazon&#8217;s cloud computing offerings):</p><p
style="padding-left: 30px;">Grid computing has been used in environments where users make few but large allocation requests. &#8230; [O]nly a few of these allocations can be serviced at a time and others need to be scheduled for when resources are released. &#8230;</p><p
style="padding-left: 30px;">Cloud computing really is about lots of small allocation requests. &#8230; The allocations are real-time and in fact there is no provision for queueing allocations until someone else releases resources. &#8230;</p><p
style="padding-left: 30px;">It’s easy to say “ah, we’ll just run some cloud management software on a bunch of machines,” but it’s a completely different matter to uphold the premise of real-time resource availability. If you fail to provide resources when they are needed, the whole paradigm falls apart and users will start hoarding servers, allocating for peak usage instead of current usage&#8230;</p><p>The comments on that post are worth reading, as well.</p><p>An <a
href="http://blog.rightscale.com/2008/05/26/define-cloud-computing/" target="_blank">earlier post</a> from Thorsten (<a
href="http://cloudcomputing.sys-con.com/node/581961" target="_blank">republished later</a> on <a
href="http://cloudcomputing.sys-con.com/" target="_blank">Cloud Computing Journal</a>) clearly and succinctly defines some terminology used to refer to different aspects of cloud computing:</p><p
style="padding-left: 30px;"><strong>Applications in the cloud</strong>: &#8230; Some company hosts an application in the internet&#8230; The service being sold (or offered in ad-sponsored form) is a complete end-user application. To me all this is SaaS, Software as a Service, looking to join the ‘cloud’ craze.</p><p
style="padding-left: 30px;"><strong>Platforms in the cloud</strong>: &#8230; where an application platform is offered to developers in the cloud. &#8230; The service being sold is the machinery that funnels requests to an application and makes the application tick.</p><p
style="padding-left: 30px;"><strong>Infrastructure in the cloud</strong>: &#8230;  the most general offering that Amazon has pioneered and where RightScale offers its management platform. &#8230; virtually any application and any configuration that is fit for the internet can be mapped to this type of service.</p><p>Again, the comments are worth reading and link to other articles on the subject.</p> ]]></content:encoded> <wfw:commentRss>http://wildblueether.com/2009/01/31/cloud-computing-grid-computing/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>When Things Go Wrong&#8230;</title><link>http://wildblueether.com/2009/01/31/when-things-go-wrong/</link> <comments>http://wildblueether.com/2009/01/31/when-things-go-wrong/#comments</comments> <pubDate>Sat, 31 Jan 2009 21:36:19 +0000</pubDate> <dc:creator>Jeremy Merrill</dc:creator> <category><![CDATA[On the Ground]]></category><guid
isPermaLink="false">http://www.wildblueether.com/?p=116</guid> <description><![CDATA[Do you have a backup and recovery plan in place for your data, that you can turn to when the inevitable (catastrophic system failure and possible data loss) happens? Do you have a revision control system in place for your source code, that you can turn to when you break something in the functionality of [...]]]></description> <content:encoded><![CDATA[<div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwildblueether.com%2F2009%2F01%2F31%2Fwhen-things-go-wrong%2F"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwildblueether.com%2F2009%2F01%2F31%2Fwhen-things-go-wrong%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br
/> </a></div><p>Do you have a backup and recovery plan in place for your data, that you can turn to when the inevitable (catastrophic system failure and possible data loss) happens? Do you have a revision control system in place for your source code, that you can turn to when you break something in the functionality of your system?</p><p>Yesterday morning, a web-based bookmarking service, <a
href="http://ma.gnolia.com/" target="_blank">ma.gnolia</a>, suffered a catastrophic failure. It will be at least a matter of days before the service returns, and users&#8217; bookmarks may be lost, either partially or completely. Michael Calore <a
href="http://blog.wired.com/business/2009/01/magnolia-suffer.html" target="_blank">writes</a> at Wired&#8217;s Epicenter blog:</p><p
style="padding-left: 30px;">In light of today&#8217;s outage, many are questioning the reliability of <a
href="http://www.cloudave.com/link/ma-gnolia-data-loss-what-have-we-learned" target="_blank">web apps</a> and <a
href="http://www.stoweboyd.com/message/2009/01/magnolia-data-corruption-how-and-what-to-back-up.html" target="_blank">web-based storage</a> in general. Twitter in particular is full of users <a
href="http://search.twitter.com/search?q=ma.gnolia" target="_blank">venting their suspicions.</a></p><p
style="padding-left: 30px;">&#8220;Cloud computing becomes fog when it goes down,&#8221; says Todd Spragins in a <a
href="http://twitter.com/bellhead/statuses/1163005116" target="_blank">Twitter post</a>.</p><p
style="padding-left: 30px;">Another common thread: People are talking about bailing on Ma.gnolia in favor of competitor Delicious.</p><p>More ammunition for the <a
href="http://ascii.textfiles.com/archives/1717" target="_blank">critics</a> (warning: NSFW) of &#8220;the cloud&#8221;, or web-based software and data storage.<br
/> <span
id="more-116"></span><br
/> This morning, the mighty Google <a
href="http://www.techcrunch.com/2009/01/31/google-flags-whole-internet-as-malware/" target="_blank">screwed up</a> and, well, &#8220;broke the Interwebs&#8221;.  For a &#8220;brief&#8221; period (less than an hour), <em>every single result</em> returned from Google&#8217;s search was flagged as potentially &#8220;harmful&#8221;, meaning the linked site was &#8220;known&#8221; to install malware upon visiting.  Google VP Marissa Mayer <a
href="http://googleblog.blogspot.com/2009/01/this-site-may-harm-your-computer-on.html" target="_blank">writes</a>:</p><p
style="padding-left: 30px;">What happened? Very simply, human error. &#8230; <span
style="color: #0b5394;">We maintain a list of such sites through both manual and automated methods &#8230; We periodically update that list and released one such update to the site this morning.</span> Unfortunately (and here&#8217;s the human error), the URL of &#8216;/&#8217; was mistakenly checked in as a value to the file[,] and &#8216;/&#8217; expands to all URLs. Fortunately, our on-call site reliability team found the problem quickly and reverted the file.</p><p>If you click on a link that&#8217;s been marked by Google in this way, you don&#8217;t go directly to the linked page.  You&#8217;re taken to a page from Google asking, and I&#8217;m paraphrasing here, &#8220;Are you sure you want to visit this page? If so, you do so at your own risk.&#8221;  You can then click through to the actual page if you wish, against the advice of Google and their partner in this flagging endeavor, <a
href="http://stopbadware.org/" target="_blank">StopBadware.org</a> (who Google initially suggested was at fault for this SNAFU &#8212; <a
href="http://blog.stopbadware.org/2009/01/31/google-glitch-causes-confusion" target="_blank">they&#8217;re not</a>).</p><p>Needless to say, this essentially ground to a halt pretty much all web browsing linked from Google search results.  Of course, as <a
href="http://leoville.com/" target="_blank">Leo Laporte</a> brought up on his <a
href="http://techguylabs.com/" target="_blank">radio show</a> today, whether Google should be flagging sites and setting up roadblocks to visiting them, based on a computer- and human-generated blacklist, without your permission, is another question entirely.  Leo <a
href="http://techguylabs.com/radio/ShowNotes/Show531#toc3" target="_blank">thinks</a> you should be able to turn off this flagging feature in Google&#8217;s settings, and that Google shouldn&#8217;t be the supreme arbiter of what we get to see on the web.</p><p>Ms. Mayer writes that the problem was taken care of &#8220;quickly&#8221;, and Leo disputes this as well (&#8220;An hour?! That&#8217;s an eternity on the Internet!&#8221; &#8212; again, paraphrasing), but this at least illustrates that they have a plan in place for rolling back to earlier revisions of critical components of their system, as quickly as possible, in the event of a breakage.</p><p>Do you?</p> ]]></content:encoded> <wfw:commentRss>http://wildblueether.com/2009/01/31/when-things-go-wrong/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using memcached

Served from: wildblueether.com @ 2012-05-21 00:40:40 -->
