Getting started with Ruby 2.0 and Rails 4.0.0 beta 1 Feb 26 2013
It’s an exciting time to be a Rubyist as we get lots of new versions of things to play with. Ruby 2.0 is finally out, and with it a raft of updates across the board for various Ruby related software, including the first beta of Rails 4!
To get up and running quickly with Ruby 2 and Rails 4 (using RVM), it’s pretty easy:
rvm get stable
rvm install 2.0.0-p0
rvm use 2.0.0-p0
rvm gemset use rails4 --create
gem install bundler
gem install rails --pre
If that last command doesn’t work, try:
gem install rails -v 4.0.0.beta1
And then when the gems are installed, you can create a new app using Rails 4 beta 1:
rails new new_rails4_app
If you have SSL cert issues with Bundler under Ruby 2.0 (it’ll error on the Rails app creation as it runs bundle install by default), then you might find that the following helps:
brew install openssl
rvm get head
rvm reinstall 2.0.0-p0
The latest RVM builds against packages found in Homebrew by default, so it’ll use the Homebrew OpenSSL. You’ll then most likely need something like these commands to sync the Homebrew OpenSSL CA certs with the system keychain, or indeed this tool will add a crontab entry that regularly keeps those certs in sync, useful if any certs change in future.
The other alternative is to skip bundling when creating the Rails app:
rails new new_rails4_app --skip-bundle
And then switch from HTTPS to HTTP in the Gemfile for the newly created app, although I wouldn’t recommend it and it’d be better if you can use the above instructions to get it working over SSL.
Once that’s all installed, you can get to grips with the latest changes in Ruby 2.0 and Rails 4.0.0, so have at it! I’ll be posting more about the features these new versions introduce shortly, so follow me on Twitter!