Ruby on Rails 3.2 ã Mac OS X ã«ã¤ã³ã¹ãã¼ã«ããæé ãããªãä¸å¯§ã«èª¬æãã¦ã¿ã¾ãã
2011/08/07
å æ¥æ²è¼ããRuby on Rails 3.1 ã Windows ã«ã¤ã³ã¹ãã¼ã«ããæé ãããªãä¸å¯§ã«èª¬æãã¦ã¿ã¾ããã®Mac OS Xãã¼ã¸ã§ã³ã§ãã
Mac OS Xã§åãã¦RubyãRailsã«ææ¦ããæ¹ã®ããã«ãææ°ã® Ruby 1.9.3 㨠Ruby on Rails 3.2 ã®ã¤ã³ã¹ãã¼ã«æé ããã詳ãã説æãã¾ãã
ãªããæ¬ç¨¿ã§ã¯Rubyã®ã¤ã³ã¹ãã¼ã«ã«Homebrewã¨rbenvãå©ç¨ãã¦ãã¾ããMacPortsã«ããã¤ã³ã¹ãã¼ã«æé ãç¥ãããæ¹ã¯ http://ref.xaio.jp/ruby/install/macosx ãåç §ãã¦ãã ããã
æ¬ç¨¿ã対象ã¨ãã OS 㯠Mac OS X 10.8 (Mountain Lion)ãMac OS X 10.7 (Lion) ãããã³ Mac OS X 10.6 (Snow Leopard) ã§ãããæé éããã£ããã©ãã¾ãè¡ããªãã£ãï¼ãã¨ããæ¹ã¯ãMac OS ã®ç¨®é¡ãæè¨ã®ä¸ãhermes_at_oiax_dot_jp ã¾ã§ã¡ã¼ã«ã§ãåãåãããã ãããã¾ããããã¡ããã¤ã³ã¹ãã¼ã«ã§ãããã©ãå¾®å¦ã«èª¬æéãã§ã¯ãªãã£ããã¨ããçµé¨ãããæ¹ãåã¢ãã¬ã¹ã¾ã§æ å ±ããå¯ãããã ããã¨å©ããã¾ãã
ãã®æç« ã®å 容ã¯ãéææ´æ°ãã¦ãã¾ããæçµæ´æ°æ¥: 2017/12/31
Xcode ã®ã¤ã³ã¹ãã¼ã«
- Mac OS X 10.8 (Mountain Lion) ããã³ Mac OS X 10.7 (Lion) ã®å ´å
- ã¡ãã¥ã¼ãã¼å·¦ç«¯ã®ãã¢ããã«ã¡ãã¥ã¼ããããApp Storeããé¸æãã¾ãã
- App Store ã¦ã£ã³ãã¦ã®å³ä¸ã«ããæ¤ç´¢ããã¯ã¹ã使ã£ã¦ãxcodeããæ¤ç´¢ãã¾ãã
- ãXcodeããã¯ãªãã¯ãã次ã®ãã¼ã¸ã§ãç¡æããã¿ã³ãã¯ãªãã¯ã㦠Xcode ãã¤ã³ã¹ãã¼ã«ãã¾ãã
- Mac OS X 10.6 (Snow Leopard) ã®å ´å
- ãã©ã¦ã¶ã§ http://developer.apple.com/jp/ ãéãã¾ãã
- ãMac Dev Centerããã¯ãªãã¯ãã¾ããããããå ã¯è±èªã§ãã
- Apple IDãæã£ã¦ããå ´åã¯ããLog inããã¿ã³ãã¯ãªãã¯ãã¦ãã°ã¤ã³ãã¾ãããã³ã: Apple IDã¯å¤åãããªãã®ã¡ã¼ã«ã¢ãã¬ã¹ã§ãã
- Apple IDãæã£ã¦ããªãå ´åã¯ãç»é¢å³ä¸ã®ãRegisterããã¯ãªãã¯ãã¾ãã次ã®ãã¼ã¸ã§ãGet Startedããã¯ãªãã¯ãã¦ã©ã¸ãªãã¿ã³ãCreate an Apple IDããé¸æãã¦ããContinueããã¿ã³ãã¯ãªãã¯ãã¾ãã以ä¸ãæ°åãä½æãé»è©±çªå·ãªã©æ§ã ãªè³ªåé ç®ã«çãã¦ãApple IDã®ç»é²ãå®äºãã¾ãã
- Mac Dev Centerã«ãã°ã¤ã³ãããXcode 3.2.6 and iOS SDK 4.3ããªã³ã¯ãã¯ãªãã¯ãã¦ã¤ã³ã¹ãã¼ã«ãã¾ãã注æ: ã¤ã³ã¹ãã¼ã«ãã¡ã¤ã«ã¯4GB以ä¸ããã¾ããæéã«ä½è£ã®ããã¨ãã«è¡ãã¾ãããã
Command Line Tools ã®ã¤ã³ã¹ãã¼ã« (Xcode ã®ãã¼ã¸ã§ã³ã 4.3 以ä¸ã®å ´å)
- Xcode ãèµ·åã
- ãXcodeãã¡ãã¥ã¼ã®ãPreferencesããé¸æã
- ãDownloadsãã¿ããé¸æãããCommand Line Toolsãã®ãInstallããã¿ã³ãã¯ãªãã¯ã
Homebrew ã®ã¤ã³ã¹ãã¼ã«
- Finderã§ãã¢ããªã±ã¼ã·ã§ã³ãâãã¦ã¼ãã£ãªãã£ãã¨é²ãã§ããã¿ã¼ããã«ããéãã¾ãã
- ã¿ã¼ããã«ã§æ¬¡ã®ã³ãã³ããå®è¡ãã¾ãã
> ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
ã³ãã³ãã®å
é ã«ãã >
ã®æåã¯å
¥åããªãã§ãã ããããã以éã®æé ã§ãåãã§ããrootã¦ã¼ã¶ã¼ã§ã¯ãªãä¸è¬ã¦ã¼ã¶ã¼ã§å®è¡ãã¦ãã ãããsudo
ãä»ããå¿
è¦ãããã¾ããã
MacPorts ã§ã¤ã³ã¹ãã¼ã«ããã Ruby ã®ã¢ã³ã¤ã³ã¹ãã¼ã«
ããªãã® Mac ã« MacPorts 㧠Ruby ãã¤ã³ã¹ãã¼ã«ããã¦ããå ´åã¯ãã¢ã³ã¤ã³ã¹ãã¼ã«ãã¾ãã
> sudo port uninstall ruby
MacPorts ã§ã¤ã³ã¹ãã¼ã«ããã Ruby ã®æç¡ã調ã¹ãã«ã¯ãwhich ruby
ã³ãã³ããå®è¡ãã¦ãã ããã/opt/local/bin/ruby
ã¨ããçµæãè¿ãã°ãé½æ§ãã§ãã
RVM ã®é¤å»
ããªãã®Macã«RVMãã¤ã³ã¹ãã¼ã«ããã¦ããå ´åã¯ãé¤å»ãã¾ãã
> rvm implode
æ¬ç¨¿ã§ã¯Rubyç°å¢ã®ç®¡çã«rbenvã使ç¨ãã¾ããRVMã¨ã¯å ±åã§ãã¾ããã
rbenv 㨠ruby-build ã®ã¤ã³ã¹ãã¼ã«
- Finderã§ãã¢ããªã±ã¼ã·ã§ã³ãâãã¦ã¼ãã£ãªãã£ãã¨é²ãã§ããã¿ã¼ããã«ããéãã¾ãã
- ã¿ã¼ããã«ã§ä»¥ä¸ã®ã³ãã³ããé ã«å®è¡ãã¾ãã
> brew install rbenv > brew install ruby-build > echo 'eval "$(rbenv init -)"' >> ~/.bash_profile > source ~/.bash_profile
brew
ã®åã« sudo
ãä»ããå¿
è¦ã¯ããã¾ãããZSHãã使ãã®æ¹ã¯ãæçµè¡ã® .bash_profile
ã .zshrc
ã§ç½®ãæãã¦ãã ããã
readline ã®ã¤ã³ã¹ãã¼ã«
- ã¿ã¼ããã«ã§ä»¥ä¸ã®ã³ãã³ããé ã«å®è¡ãã¾ãã
> brew install readline > brew link readline
openssl ã®ã¤ã³ã¹ãã¼ã«
- ã¿ã¼ããã«ã§ä»¥ä¸ã®ã³ãã³ããé ã«å®è¡ãã¾ãã
> brew install openssl > brew link openssl
ruby ã®ã¤ã³ã¹ãã¼ã«
- ã¿ã¼ããã«ã§æ¬¡ã®ã³ãã³ããå®è¡ãã¾ãã
> CONFIGURE_OPTS="--with-readline-dir=/usr/local --with-openssl-dir=/usr/local" rbenv install 1.9.3-p194 > rbenv rehash > rbenv global 1.9.3-p194
2012å¹´9æ15æ¥ã«ãããRubyã®ææ°ç1.9.3p194ãã¤ã³ã¹ãã¼ã«ãã¦ãã¾ãã
- rbenvã®è¨å®ã確èªãã¾ãã
> rbenv version
1.9.3-p194
ã«å§ã¾ãæååã表示ããããã¨ã確èªãã¦ãã ããã
- ã¿ã¼ããã«ã§rubyã®ãã¼ã¸ã§ã³ã確èªãã¾ãã
> ruby -v
ruby 1.9.3p194
ã«å§ã¾ãæåãç¾ãããã¨ã確èªãã¦ãã ããã
.gemrc ã®ä½æ
- ã¨ãã£ã¿ã§
~/.gemrc
ã次ã®ãããªå 容ã§ä½æãã¾ãã
install: --no-ri --no-rdoc update: --no-ri --no-rdoc
Ruby on Rails 3.2 ã®ã¤ã³ã¹ãã¼ã«
- ã¿ã¼ããã«ã§ã次ã®ã³ãã³ããå®è¡ãã¾ãã
> rbenv exec gem install rails --version="~> 3.2.8" > rbenv rehash > source ~/.bash_profile
- ã¿ã¼ããã«ã§ Ruby on Rails ã®ãã¼ã¸ã§ã³ã確èªãã¾ãã
> rails -v
Rails 3.2.8
ã¨ããæåãç¾ãããã¨ã確èªãã¦ãã ããããRails is not currently installed on this system. ...ãã¨ããã¨ã©ã¼ã¡ãã»ã¼ã¸ãç¾ããããrbenv exec gem install railties --version="~> 3.2.8"
ã³ãã³ã㨠rbenv rehash
ã³ãã³ããé ã«å®è¡ãã¦ãããä¸åº¦ Rails ã®ãã¼ã¸ã§ã³ã確èªãã¦ãã ãããåèè³æ: https://github.com/sstephenson/rbenv/issues/73
ä½æ¥ãã©ã«ãã®ä½æ
- ã¿ã¼ããã«ã§ã以ä¸ã®ã³ãã³ããé ã«å®è¡ãã¾ããéä¸ã§ç¾ãã
work
ã¯ä½æ¥ãã©ã«ãã®ååã§ãã好ããªååã§ç½®ãæãã¦ãã ããã
> cd > mkdir work
åä½ç¢ºèªç¨ã®æ°è¦ã¢ããªã±ã¼ã·ã§ã³ã®ä½æ
- ã¿ã¼ããã«ã§ã以ä¸ã®ã³ãã³ããé ã«å®è¡ãã¾ããéä¸ã§ç¾ãã
foo
ã¯åä½ç¢ºèªç¨ã«ä½æããã¢ããªã±ã¼ã·ã§ã³ã®ååã§ãã好ããªååã§ç½®ãæãã¦ãã ããã
> cd work > rails new foo --skip-bundle > cd foo
é常ã®æ°è¦ã¢ããªã±ã¼ã·ã§ã³ã®ä½æã§ã¯--skip-bundle
ãªãã·ã§ã³ãä»ããã« rails new
ã³ãã³ããå®è¡ãã¾ãããã®å ´åã次é
ã§èª¬æãã bundle install
ã«ããä¾åããã±ã¼ã¸ã®ã¤ã³ã¹ãã¼ã«ãåæã«è¡ããã¾ããæ¬ç¨¿ã§ã¯ãåå¿è
ã®æ¹ãåé¡ã®æå¨ãææ¡ããããããã«ãã¨ã®é
æ
®ãã--skip-bundle
ãªãã·ã§ã³ãä»ãã¦ãã¾ãã
ä¾åããã±ã¼ã¸ã®ã¤ã³ã¹ãã¼ã«
- ã¿ã¼ããã«ã§ã以ä¸ã®ã³ãã³ããé ã«å®è¡ãã¾ãã
> bundle install
ããªãæéããããããããã¾ãããæ°é·ã«å¾ ã¡ã¾ãããã
ç°¡åãªã¦ã¼ã¶ã¼ç®¡çæ©è½ã®ä½æ
- ã¿ã¼ããã«ã§ã以ä¸ã®ã³ãã³ããé ã«å®è¡ãã¾ãã
> rails g scaffold user name:string email:string > rake db:migrate
ã¢ããªã±ã¼ã·ã§ã³ã®èµ·å
- ã¿ã¼ããã«ã§ã次ã®ã³ãã³ããå®è¡ãã¾ãã
> rails s
åä½ç¢ºèª
- ãã©ã¦ã¶ã§
http://localhost:3000/users
ãéãã¾ãã - ãListing usersãã¨ããè¦åºããæã¤ãã¼ã¸ã表示ããã¾ãã
- ãNew Userããªã³ã¯ãã¯ãªãã¯ãã¾ãã
- ãNameãæ¬ã«ããªãã®ååããEmailãæ¬ã«ããªãã®ã¡ã¼ã«ã¢ãã¬ã¹ãå ¥åãããCreate Userããã¿ã³ãã¯ãªãã¯ãã¾ãã
- ãã¼ã¸ã®ä¸é¨ã«ãUser was successfully created.ãã¨è¡¨ç¤ºãããã° OK ã§ãã
[æ´æ°] OS X ã®ããã±ã¼ã¸ç®¡çã·ã¹ãã ã MacPorts ãã Homebrew ã«å¤æ´ãã¾ããã(2011/08/07)
[æ´æ°] Xcode ã®ã¤ã³ã¹ãã¼ã«æé ãLionã¨Snow Leopardã§åãã¾ãããã¾ããåããã«ãã表ç¾ãããã¤ãæ¹ãã¾ããã(2011/08/28)
[æ´æ°] Rails 3.1.0ã®æ£å¼ãªãªã¼ã¹ã«åããã¦ã微修æ£ãã¾ãããã¾ãããRakeã®æ´æ°ãã追å ããuninitialized constant Rake::DSL
ã¨ããã¨ã©ã¼ã¸ã®å¯¾å¦æ³ãåé¤ãã¾ããã(2011/09/01)
[æ´æ°] https://github.com/mxcl/homebrew/wiki/installationãåèã«Homebrewãã¤ã³ã¹ãã¼ã«ããããã®ã³ãã³ããæ´æ°ãã¾ãããã¾ãã¿ã¤ãã«ããã³æ¬æä¸ã®ãRails 3.1ãããRails 3.2ãã¨æ¹ãã¾ããã(2012/03/29)
[æ´æ°] MacPortsã«ããRubyã®ã¤ã³ã¹ãã¼ã«æé ã説æãã¦ãã http://ref.xaio.jp/ruby/install/macosx ã¸ã®ãªã³ã¯ã追å ãã¾ããã(2012/04/02)
[æ´æ°] Rubyã®ãã¼ã¸ã§ã³çªå·ã確èªããæé ã¨ç°å¢å¤æ°PATHã«é¢ããå²ã¿è¨äºã追å ãã¾ãããã¾ããMac OS X 10.7 (Lion) ã®å ´åã§ãHomebrewã§ææ°çã®Rubyãã¤ã³ã¹ãã¼ã«ããããã«æé ãå¤æ´ãã¾ããã(2012/04/13)
[æ´æ°] Rubyã®ã¤ã³ã¹ãã¼ã«ã«rbenvã使ç¨ãããããå¤§å¹ ã«æ¸ãæãã¾ãããHow to setup Mac OS X Lion for ruby and rails development 㨠Mac OS X(Lion)ã«Ruby on Rails 3.2ã®éçºç°å¢ãæ§ç¯ãã ãåèã«ãã¦ãã¾ãã(2012/04/22)
[æ´æ°] .bash_profile
ã .bashrc
ã«ã.zsh_env
ã .zshrc
ã«å¤æ´ãã¾ããã(2012/05/02)
[æ´æ°] Railsãã¤ã³ã¹ãã¼ã«ããç´å¾ã«rbenv rehash
ã³ãã³ããå®è¡ããæé ã追å ãã¾ããã(2012/05/09)
[æ´æ°] Rubyãã¤ã³ã¹ãã¼ã«ããç´å¾ã«rbenv version
ã³ãã³ãã§è¨å®ã確èªããæé ã追å ãã¾ããã(2012/05/09)
[æ´æ°] Xcodeãã¤ã³ã¹ãã¼ã«ããç´å¾ã«Command Line Tools
ãã¤ã³ã¹ãã¼ã«ããæé ã追å ãã¾ããã(2012/05/28)
[æ´æ°] .bashrc
ã .bash_profile
ã«æ»ãã¾ããã(2012/06/02)
[æ´æ°] Railsãã¤ã³ã¹ãã¼ã«ããã³ãã³ãã®åã« rbenv exec
ãä»ãã¾ãããã¾ããRailsã®ãã¼ã¸ã§ã³ã確èªããæé ãå ããæ£ããã¤ã³ã¹ãã¼ã«ãããªãã£ãå ´åã®å¯¾å¦æ³ã追å ãã¾ããã(2012/06/03)
[æ´æ°] MacPortsã§ã¤ã³ã¹ãã¼ã«ããRubyãé¤å»ããæé ã追å ãã¾ããã(2012/06/12)
[æ´æ°] bundle install
æã«ã»ã°ã¡ã³ãã¼ã·ã§ã³ãã©ã¼ã«ããçºçããåé¡ã«ã¤ãã¦ã®æ³¨ææ¸ãã追å ãã¾ããã(2012/07/05)
[æ´æ°] Mac OS X 10.8 (Mountain Lion) ãè¨äºã®å¯¾è±¡ã«å ãã¾ããã(2012/07/30)
[æ´æ°] Homebrewã®ã¤ã³ã¹ãã¼ã«ãä¸è¬ã¦ã¼ã¶ã¼ã§sudo
ãªãã§å®è¡ããããã«æ³¨ææ¸ããå ãã¾ããã(2012/07/30)
[æ´æ°] èªè ããã®ææã«ãããHomebrewã®ã¤ã³ã¹ãã¼ã«ã³ãã³ããæ¹è¨ãã¾ãããã¾ããã¤ã³ã¹ãã¼ã«ãããRailsã®ãã¼ã¸ã§ã³ã3.2.8ã«å¤æ´ãã¾ããã(2012/09/15)
[æ´æ°] èªè
ã®æ¹ããã®ææãåãã¦ãrails new
ã³ãã³ãã« --skip-bundle
ãªãã·ã§ã³ãä»ããçç±ã«ã¤ãã¦æ³¨éãå ãã¾ããã(2012/09/18)
[æ´æ°] èªè
ã®æ¹ããã®å©è¨ã«ãããHomeBrew 㧠openssl
ãã¤ã³ã¹ãã¼ã«ããæé ã追å ãã¾ããã以åã¯ãbundle install
å®è¡æã« Segmentation fault
ãçºçããå ´åã®å¯¾å¦æ³ã¨ãã¦ãMacPorts ã§ã¤ã³ã¹ãã¼ã«ãã openssl
ãç¨ãã¦ã--with-openssl=/opt/local
ãªãã·ã§ã³ãç°å¢å¤æ° CONFIGURE_OPTS
ã«å ããã¨ãã対å¦æ³ãå²ã¿è¨äºã®ä¸ã§ç´¹ä»ãã¦ãã¾ããã(2012/09/18)
[æ´æ°] èªè
ã®æ¹ããã®å ±åãåãã¦ãRailsã®ã¤ã³ã¹ãã¼ã«ç´å¾ã« source ~/.bash_profile
ãå®è¡ããæé ãå ãã¾ãããé常ããã®æé ã¯å¿
è¦ãªãã¯ãã§ããããã®æé ãè¸ã¾ãªãã¨æ£ãã rails
ã³ãã³ããèªèãããªãå ´åãããããã§ãã(2012/10/02)