devroom.io/drafts/2009-01-04-how-to-start-a-rails-edge-app-the-easy-way.md

67 lines
3.3 KiB
Markdown
Raw Normal View History

2013-03-22 22:53:57 +00:00
---
title: "How To Start A Rails Edge App The Easy Way"
kind: article
slug: how-to-start-a-rails-edge-app-the-easy-way
created_at: 2009-01-04
tags:
- General
- RubyOnRails
- Rails
- git
- ror
- edge
- submodule
---
There's a lot of <a href="http://blog.rubyonrails.com/2009/1/2/this-week-in-edge-rails">cool</a> <a href="http://blog.rubyonrails.com/2008/12/26/this-week-in-edge-rails">stuff</a> <a href="http://blog.rubyonrails.com/2008/12/23/merb-gets-merged-into-rails-3">pooring in</a> about what's new in Rails Edge (which will become Rails 2.3 and/or Rails 3).
Most likely you can't wait to get started with these new features, especially when you're about to start a new project, which doesn't have to be stable yet, but will be by the time 2.3/3.0 come out. This post shows you the way to create a new Rails app based on the most current Rails code, also called Edge Rails.
Let's go...
<pre lang="sh">
mkdir -p myapp/vendor
cd myapp
git init
git submodule add git://github.com/rails/rails.git vendor/rails
git commit -m "Frozen Rails Edge as submodule"
ruby vendor/rails/railties/bin/rails .
# Add generated files to git, and code on...</pre>
First, you create a new directory for your app, including the <code>vendor</code> directory. Easy, right?
Next, you initialize a Git repository for your empty project. We'll be using Git to track the remote Rails Edge code. Stay with me.
By adding a Git submodule we tell git to clone the code from <code>git://github.com/rails/rails.git</code> into the <code>vendor/rails</code> directory. Nice! If you check the current git status with <code>git status</code> you see git has already staged two files for you, <code>.gitmodules</code> and <code>vendor/rails</code>. Commit them now to attach the submodule to your local git repository.
Git will not automatically update your submodule, you'll have to do that by hand. I'll show you this in a minute.
With <code>vendor/rails</code> containing Rails Edge, you can now generate your Rails Edge application. In you project directory (<code>myapp/</code>), you call <code>ruby vendor/rails/railties/bin/rails .</code>. This will generate a new Rails Edge application in the current directory.
Now it's up to you to create a fitting <code>.gitignore</code> file and commit the files to your repository.
That's all, you now have a new Rails Edge application. Try <code>ruby script/server</code> to see it all in action. Enjoy!
<strong>Cloning your project</strong>
At some point you'll push your <code>myapp</code> project to a remote git server. When you clone a fresh copy, you'll have to initialize the git submodules. This is quite easy:
<pre lang="sh">
git submodule init
git submodule update</pre>
<strong>Updating Rails Edge</strong>
As I said earlier, Git will not keep your submodules up-to-date for you, but will stick with the revision you added. To keep track of Rails Edge's progress, you'll need to update the submodule. This is done like this:
<pre lang="sh">cd myapp/vendor/rails
git remote update
git merge origin/master</pre>
This will update your Rails Edge code. Make a commit, stating you updated the code!
After updating Rails Edge, you may want to update your rails application (like javascript files, config files etc).
<pre lang="sh">rake rails:update</pre>
Good luck! And happy coding!