2012-12-20

Ruby on Rails勉強再開

Ruby on Railsの勉強を再開する。
5,6年前になるかな? Railsが注目されだした頃に勉強し始めてアプリを一本作ってみた。
その頃は、日本語化や携帯電話対応がちょっと面倒だったので、本格的に業務アプリに使うにはまだ早いかなという印象だったので、一旦中断した。(情報収集は続けていたが…)
Rubyが1.9、Railsが3.2と、だいぶ進化したようなので、勉強を再開してみる。

まずはRubyのインストール。
  • RubyサイトダウンロードからWindows用のバイナリをダウンロードする。
  • 「各環境用のバイナリ」-「Windows版Rubyバイナリ 」-「One-Click Ruby Installer for Windows」のリンクをクリックする
  • RubyInstaller for Windowsのサイトが開くので、[Download]をクリックする
  • RubyInstallersから最新バージョンをダウンロードする(2012.12.20現在は、Ruby 1.9.3-p327)
  • ダウンロードしたインストーラーを実行してインストールする("Add Ruby executables to your PATH"をチェックする)
  • インストールが終わったら、コマンドプロンプトを開いてRubyのバージョンを確認しておく
ruby -v
ruby 1.9.3p327 (2012-11-10) [i386-mingw32]

次にRailsのインストール
  • まずは、RubyGemsのアップデートを行う
    gem update --system
  • Railsのインストールを行う
    gem install rails
  • インストールされたrailsのバージョンを確認しておく
    rails -v
    Rails 3.2.9

これで準備は整った。

2012.12.26 追記
rails newでアプリ作成したら下記エラーが発生したので、DevKitをインストールする。
ここ→「はじめてのRuby on Rails3」サポートページ「DevKitの使い方」を参考に設定する。
Installing json (1.7.5)
Gem::InstallError: The 'json' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
An error occurred while installing json (1.7.5), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.5'` succeeds before bundling.
  • RubyのインストーラーをダウンロードしたRubyInstaller for Windowsにある"Development Kit"からDevKit-tdm-32-4.5.2-20111229-1559-sfx.exeをダウンロードする。
  • ダウンロードしたexeファイルを実行して展開する。展開先は"\devkit"とか適当に。
  • DevKitの初期化を行う
    > cd \devkit
    > ruby dk.rb init
    [INFO] found RubyInstaller v1.9.3 at C:/Ruby193

    Initialization complete! Please review and modify the auto-generated
    'config.yml' file to ensure it contains the root directories to all
    of the installed Rubies you want enhanced by the DevKit.
  • DevKitのインストールを行う
    > ruby dk.rb install
    [INFO] Updating convenience notice gem override for 'C:/Ruby193'
    [INFO] Installing 'C:/Ruby193/lib/ruby/site_ruby/devkit.rb'
これで大丈夫かな?

0 件のコメント: