何を作るか
今回気持ちを新たにrailsアプリケーションを作ってみる。。が!
何を作ろうかと思っていましたら、ちょうど昔作った「家計簿アプリ」を
スマホでも見たいという話もあって、WEBアプリケーションとして作成しようと
決めました。
まずは、、
環境が若干古いので、全てアップデート。
【現在の環境】
Mac Book Air
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin12.2.0]
$ rails -v
Rails 3.0.17
古いなあorz。でも前のバージョンを使ってなんやかんやする時もあるかもしれないので、
色んなRubyのバージョンを管理してくれる、RVMを使用する。
上記サイトを参考に、RVMをインストール。
$ git clone --depth 1 git://github.com/wayneeseguin/rvm.git
Cloning into 'rvm'...
remote: Counting objects: 502, done.
remote: Compressing objects: 100% (389/389), done.
remote: Total 502 (delta 41), reused 381 (delta 38)
Receiving objects: 100% (502/502), 1.06 MiB | 235.00 KiB/s, done.
Resolving deltas: 100% (41/41), done.
Checking connectivity... done
$ ls
rvm tig
$ cd rvm
$ ls
CONTRIBUTING.md VERSION lib
FORMATTING.md bin man
HACKING.md binscripts patches
History.txt config patchsets
LICENCE contrib rvm-test
NEXT.md examples rvm-test-rvm1
README gemsets scripts
README.rdoc help update-remote.sh
README.txt hooks
Rakefile install
$ ./install
Installing RVM to /Users/{ユーザ名}/.rvm/
Adding rvm PATH line to /Users/{ユーザ名}/.profile /Users/{ユーザ名}/.bashrc /Users/{ユーザ名}/.zshrc.
RVM sourcing line found in /Users/{ユーザ名}/.bash_profile.
RVM sourcing line not found for Zsh, run the installer with '--auto-dotfiles' to fix it.
Installation of RVM in /Users/{ユーザ名}/.rvm/ is almost complete:
* To start using RVM you need to run `source /Users/{ユーザ名}/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
# XXXXXXXXX,
#
# Thank you for using RVM!
# We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.
In case of problems: http://rvm.io/help and https://twitter.com/rvm_io
Help RVM 2.0: https://www.bountysource.com/fundraisers/489-rvm-2-0
* WARNING: You have '~/.profile' file, you might want to load it,
to do that add the following line to '/Users/{ユーザ名}/.bash_profile':
source ~/.profile
インストール確認の為、rvm infoを実行
$ rvm info
system:
system:
uname: "Darwin MacBook-Air.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64"
system: "osx/10.9/x86_64"
bash: "/bin/bash => GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)"
zsh: "/bin/zsh => zsh 5.0.2 (x86_64-apple-darwin13.0)"
rvm:
version: "rvm 1.25.8 (manual) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
updated: "31 seconds ago"
path: "/Users/{ユーザ名}/.rvm"
homes:
gem: "not set"
ruby: "not set"
binaries:
ruby: "/Users/{ユーザ名}/.rbenv/shims/ruby"
irb: "/Users/{ユーザ名}/.rbenv/shims/irb"
gem: "/Users/{ユーザ名}/.rbenv/shims/gem"
rake: "/Users/{ユーザ名}/.rbenv/shims/rake"
environment:
PATH: "/usr/local/heroku/bin:/Users/{ユーザ名}/.rbenv/shims:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/{ユーザ名}/.rvm/bin"
GEM_HOME: ""
GEM_PATH: ""
MY_RUBY_HOME: ""
IRBRC: ""
RUBYOPT: ""
gemset: ""
うまくインストールされたっぽい。
次にruby 2.0.0をインストール。
$ rvm install 2.0.0
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.9/x86_64/ruby-2.0.0-p353.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
Updating system................................................................
Installing required packages: autoconf, automake, libtool, libyaml, libksba....
Updating certificates in '/usr/local/etc/openssl/cert.pem'.
Requirements installation successful.
Installing Ruby from source to: /Users/{ユーザ名}/.rvm/rubies/ruby-2.0.0-p353, this may take a while depending on your cpu(s)...
ruby-2.0.0-p353 - #downloading ruby-2.0.0-p353, this may take a while depending on your connection...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 10.2M 100 10.2M 0 0 1093k 0 0:00:09 0:00:09 --:--:-- 1065k
ruby-2.0.0-p353 - #extracting ruby-2.0.0-p353 to /Users/{ユーザ名}/.rvm/src/ruby-2.0.0-p353.
ruby-2.0.0-p353 - #configuring.................................................
ruby-2.0.0-p353 - #post-configuration.
ruby-2.0.0-p353 - #compiling.............................................................-
ruby-2.0.0-p353 - #installing...............
ruby-2.0.0-p353 - #making binaries executable.
ruby-2.0.0-p353 - #downloading rubygems-2.2.0
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 400k 100 400k 0 0 755k 0 --:--:-- --:--:-- --:--:-- 755k
ruby-2.0.0-p353 - #extracting rubygems-2.2.0.
ruby-2.0.0-p353 - #removing old rubygems.
ruby-2.0.0-p353 - #installing rubygems-2.2.0..
ruby-2.0.0-p353 - #gemset created /Users/{ユーザ名}/.rvm/gems/ruby-2.0.0-p353@global
ruby-2.0.0-p353 - #importing gemset /Users/{ユーザ名}/.rvm/gemsets/global.gems......|
ruby-2.0.0-p353 - #generating global wrappers.
ruby-2.0.0-p353 - #gemset created /Users/{ユーザ名}/.rvm/gems/ruby-2.0.0-p353
ruby-2.0.0-p353 - #generating default wrappers.
ruby-2.0.0-p353 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.0.0-p353 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]
ruby 2.0.0がインストールされました。
次にrailsのインストールですが、rvmにはrailsの環境を整えるのに便利なgemsetというのが
あるらしいです。
新しいruby 2.0.0のgem環境なので、上記サイトにあるようにあまりgemが入ってないかと
思いきや、なんやかんや入っていました。
$ which ruby
/Users/{ユーザ名}/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
$ gem list
*** LOCAL GEMS ***
bigdecimal (1.2.0)
bundler (1.5.1)
bundler-unload (1.0.2)
executable-hooks (1.2.6)
gem-wrappers (1.2.1)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
rubygems-bundler (1.4.2)
rvm (1.11.3.8)
test-unit (2.0.0.0)
$ which gem
/Users/{ユーザ名}/.rvm/rubies/ruby-2.0.0-p353/bin/gem
$
rails用に新規のgemsetを作成。
$ rvm gemset list
gemsets for ruby-2.0.0-p353 (found in /Users/{ユーザ名}/.rvm/gems/ruby-2.0.0-p353)
=> (default)
global
$ rvm gemset create rails40
ruby-2.0.0-p353 - #gemset created /Users/{ユーザ名}/.rvm/gems/ruby-2.0.0-p353@rails40
ruby-2.0.0-p353 - #generating rails40 wrappers.
$ rvm gemset list
gemsets for ruby-2.0.0-p353 (found in /Users/{ユーザ名}/.rvm/gems/ruby-2.0.0-p353)
=> (default)
global
rails40
作成した環境へ切り替える。
$ rvm 2.0.0@rails40
$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]
$ rvm gemset list
gemsets for ruby-2.0.0-p353 (found in /Users/{ユーザ名}/.rvm/gems/ruby-2.0.0-p353)
(default)
global
=> rails40
この環境のgemにrailsをインストールする。
無事railsをインストール。
新規プロジェクト作成し、起動を確認。ん〜なんとかうまくいってる感じ。