Search This Blog

Saturday, November 5, 2011

Ruby on Rails set up on Apple Mac OS X

Hey guys.. 


Recently I setup rails in my new Apple Mac OS X Lion 10.7. Here's the steps I followed..


1. Firstly, install XCode onto your Mac machine. Xcode is a suite of tools, developed by Apple, for developing software for Mac OS X and iOS
  • You can install XCode from the application DVD thats shipped in along with your MacBook. If its not present, then its available on the Mac App Store for free for Mac OS X 10.7, however it requires a registered Apple ID (also requires a credit card to register. damn you!).
  • Well, if you are installing it through Mac App Store, then I recommend you do start it by twilight so thats its complete by the next day morning (Took me hell lot of time man!)
  • Ruby comes preinstalled on your Mac. But its an older version! XCode also contains Git by default. you can check the version of Git by 
git --version  
  •  If Git is not installed by default, you need to install it by using HomeBrew. So first lets install Brew and then Git:
ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)" 
brew install git
 2. After installing the XCode, you need to install RVM. Here's how you can do it..
bash < <( curl -s https://rvm.beginrescueend.com/install/rvm ) 
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" ' >> ~/.bash_profile
  •  close the terminal and reopen a new one and enter this:
type rvm | head -1
  •  This will output "rvm is a function" which means RVM is installed!

3. Now lets install the
Ruby version 1.9.2. Here's the command for that:
rvm install ruby-1.9.2-p290
  •  So now, just do
rvm list
  • And you wil see the newly installed ruby.. When it's done, set Ruby 1.9.2 as the current Ruby version in your Terminal session by typing
rvm use ruby-1.9.2-p290
  • If you restart Terminal, and type "ruby -v" again, you’ll likely find that it has defaulted back to the system version of Ruby: 1.8.7. That’s no good! Let’s be sure to make 1.9.2 the default. Here's the command:
rvm --default use ruby-1.9.2-p290
  • Now, lets update the ruby gems and rake by:
gem update --system
sudo gem update rake

4. Finally, the time has come to install Rails 3.1.0 in your Mac:
gem install rails --version=3.1.0 --include-dependencies
  •  This will install Rails along with the required dependencies.
  • If you need MySQL of PostgreSQL, Make sure you have installed HomeBrew which is covered above.


Installing MySQL:
brew install mysql
  •  Make sure that you follow the instructions at the end to complete the installation and setup. You can review the post install instructions at any time by using the Homebrew info command.
brew info mysql

 Installing PostgreSQL:
brew install postgres
  • Again, make sure that you follow the instructions at the end to complete the installation and setup. As with MySQL, you can review the post install instructions at any time by using the Homebrew info command.
brew info postgres
Thats it folks, you are ready to go!