Starting Rails 3 app
So, after Yehuda’s presentation about Rails 3 (video) I’ve decided to try it out. I’ve fount a post about Rails 3 by Dr. Nic and was set a bit off because all the mess that’s still in Rails 3. Though, bundler-0.7.1 fixes rails 3 bundling. So here’s a quick howto for starting rails 3.0.pre app with new bundler.
First things firs. We need a new bundler.
gem install bundler --no-ri --no-rdoc -v '>= 0.7.1'
Now we have to create a directory for a new app.
mkdir new_rails_app
cd new_rails_app
Note: currently rails generator can’t handle app names with dashes correctly. If you need dashes in app dir name start with underscores and rename the dir after you generate the app.
Now we need a Gemfile for edge rails. Here it is.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21# I prefere to have everything bundled.
# So to be sure the no gems missed I disable system gems.
disable_system_gems
# Add Gemcuter source
source 'http://gemcutter.org/'
# arel depends on activesupport. So we describe it here
# separated from other rails gems.
gem 'activesupport', '3.0.pre', :path => 'activesupport',
:git => "git://github.com/rails/rails.git"
gem 'arel', '0.2.pre', :git => 'git://github.com/rails/arel.git'
# Bundle edge rails
# Note that rails gem is not listed here. railsties listed instead.
git "git://github.com/rails/rails.git" do
%w(activemodel activerecord actionpack actionmailer
activeresource railties).each do |gem_name|
gem gem_name, '3.0.pre', :path => gem_name
end
end
At this point we should have all needed gems bundled and ready to create our app.
./bin/rails .
Note: skip overwriting Gemfile
Now we can try to start our app, but I have to warn: ./script/server
is broken atm. But Rails 3 app is a rack app. You can see a config.ru
file in the root of our app. We can user rackup to start our app.
./bin/rackup -p 3000
I added port parameter because default for rackup is 9292, but 3000
is the one every rails developer used to.
Update Jan 11, 2010: updated Gemfile