Creating a Rails 3 application from a source install

I decided to make a quick post about creating a Rails 3 app from a source install of Rails because setup in Edge Rails changes so often and the documentation is usually outdated.

So here you go:

Clone the rails repo from github

bob@guinness ~/projects  $ git clone http://github.com/rails/rails.git
Initialized empty Git repository in /Users/bob/projects/rails/.git/
got 78fffac66895b0239b83138d19ae09b32718cb5b
walk 78fffac66895b0239b83138d19ae09b32718cb5b
...
cd rails   # Don't forget this or you will be in the wrong directory for the rest of the tutorial

Only do this if you have a an old version of bundler

bob@guinness ~/projects/rails $ rm -rf ~/.bundle/ ~/.gem/ .bundle/ Gemfile.lock

My version of rubygems was old and didn’t support the new bundler version

bob@guinness ~/projects/rails $ sudo gem update --system --no-ri --no-rdoc
Updating RubyGems
Nothing to update

Get the updated bundler

bob@guinness ~/projects/rails $ sudo gem install bundler --no-ri --no-rdoc
Successfully installed bundler-0.9.25
1 gem installed

You’ll need thor

bob@guinness ~/projects  $ sudo gem install thor --no-rdoc --no-ri
Successfully installed thor-0.13.6
1 gem installed

Bundle the rails dependencies

bob@guinness ~/projects/rails $ bundle install
Fetching git://github.com/rails/arel.git
Fetching source index from http://rubygems.org/
Updating git://github.com/rails/arel.git
Using rake (0.8.7) from system gems
Installing RedCloth (4.2.3) from rubygems repository at http://rubygems.org/ with native extensions
Using abstract (1.0.0) from system gems
Using builder (2.1.2) from system gems
Installing i18n (0.4.0.beta1) from rubygems repository at http://rubygems.org/
# There will be quite a few dependencies installed by bundler
...
Installing yajl-ruby (0.7.6) from rubygems repository at http://rubygems.org/ with native extensions Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Make sure it all worked out :)

bob@guinness ~/projects/rails $ bundle show arel
/Users/bob/.bundle/ruby/1.8/bundler/gems/arel-8151ac946644aab31601d7c0ed944eb9d7ea1e6b-master

Create your rails app

bob@guinness ~/projects/rails $ ruby bin/rails ../rails3app --dev
create
create  README
create  Rakefile
create  config.ru
create  .gitignore
create  Gemfile
create  app
create  app/controllers/application_controller.rb
create  app/helpers/application_helper.rb
... # This is standard rails 3 application scaffolding
create  vendor/plugins/.gitkeep
run  bundle install from "."

Start your rails 3 app

bob@guinness ~/projects/rails $ cd ../rails3app
bob@guinness ~/projects/rails3app  $ script/rails server
=> Booting WEBrick
=> Rails 3.0.0.beta3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-05-24 22:41:47] INFO  WEBrick 1.3.1
[2010-05-24 22:41:47] INFO  ruby 1.8.7 (2009-06-12) [i686-darwin10]
[2010-05-24 22:41:47] INFO  WEBrick::HTTPServer#start: pid=38457 port=3000

Point your browser at http://localhost:3000.

BAM! You are running your Rails 3 app from a source install.

One Comment

  1. I can’t even plug a plug into a plug. Where do I put this disk? Into the screen?

Leave a Reply