Skip to content

Instantly share code, notes, and snippets.

@mochiz
Last active December 14, 2015 04:19
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mochiz/5027808 to your computer and use it in GitHub Desktop.
Save mochiz/5027808 to your computer and use it in GitHub Desktop.
Ruby2 + Rails4環境を構築する(2013/02/25版)

更新日:2013/02/26

※WEB+DB PRESS vol.73のRails4特集を写経したくてRuby2 + Rails4環境を構築した際のメモです。
まっとうな手順ではないので、大人しく正式リリースを待ったほうがいいと思いますが

2013/02/26 追記

gemがリリースされたので、ふつうにgem installするといいですよ

$ gem install rails --version 4.0.0.beta1

Ruby2をインストール

手順はこちら
rbenvとruby-buildでRuby環境を最新に保つ

bundler更新

Rails4はbundler1.3以上が必須なのでバージョンを指定してインストールします。
※2013/02/25時点

gem install bundler --version ">= 1.3.0.pre2"

Rails4をclone & newしてみる

2012/02/25時点で、Rails4はgemで提供されていないので、git cloneします。
※全てcloneすると負荷が高いので、最新のものだけ

$ cd ~/Sites/github
$ git clone https://github.com/rails/rails.git --depth 5

cloneしたコードからアプリを作成します。
必要なgemが無いとエラーになると思います。

$ cd ~/Sites/ruby2/rails4
$ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.1]
$ ~/Sites/github/rails/railties/bin/rails new tetsuzine --edge --skip-bundle
/Users/asakura/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- thread_safe (LoadError)
...

必要なgemをインストール

Gemfileからbundle installします。
※2013/02/25時点、rails, sprockets-rails, sass-rails, coffee-railsはリポジトリとバージョンを指定する必要があります。

$ less Gemfile
source 'https://rubygems.org'
gem 'rails', '~> 4.0.0.beta', :git => 'git://github.com/rails/rails.git'
group :assets do
  gem 'sprockets-rails', '~> 2.0.0.rc1'
  gem 'sass-rails',   '~> 4.0.0.beta', :git => 'git://github.com/rails/sass-rails.git'
  gem 'coffee-rails', '~> 4.0.0.beta', :git => 'git://github.com/rails/coffee-rails.git'
  gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.0.1'
$ bundle install

Rails4をnewしてみる

--edgeを忘れないようにnewコマンドを実行します。

$ ~/Sites/github/rails/railties/bin/rails new tetsuzine --edge
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
...

無事にnew出来たようです。
Rails Serverを起動してみます。

$ cd tetsuzine
$ bundle exec rails server

screenshot 2013-02-25 at 13 49 39

やったねたえちゃん、Rails4だよ

とりあえずここまで、ガクリ

追記

WEB+DB PRESS vol.73のRails4特集記事を写経しました

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment