How To Download Ruby On Rails For Mac



Need some help figuring out how to set up Ruby on Rails from the Apple Mac OS X terminal? Let this video be your guide! Whether you're entirely new to Ruby on Rails 3 or are a seasoned developer merely looking to brush up on a few of the basics, you're sure to find much to take away. Jul 16, 2017 The simplicity of this software developer in forms of Ruby as a language program and Rails as framework are what make this preferred by many. For those who want to learn more about this amazing software developer, it would be better to install Ruby on Rails beforehand. In this article, we give you a guide on how to install Ruby on Rails on MacOS.

In this tutorial i will guide you through the steps for installing ruby and rails gem on your freshly installed MacOS X mavericks 10.9 . in this tutorial i will use RVM ( ruby version manager ) to install ruby and nano as a text editor . so let’s get started

Install required Components

1 . xcode (command line tools )

Rails

$ rvm use ruby-2.2.0@rails4.2 -create. At the time of this writing, rails 4.2 is the current version. If a new version is out you can name the gemset it appropriately. Use the following to install the latest version of rails: $ gem install rails. After it finishes installing, check that rails is installed: $ rails -v.

Install xcode and then install command line tools or just install command line tools stand alone . open terminal and type

and choose install
2 . Homebrew

homebrew is awesome package manager for mac , if you used mac before its most chances that you know about that and for the newbie its like apt-get and yum-install tool for mac

open terminal and paste :

after installation open terminal and run

Start Installation

1 . Installing mysql ( & setup path )]

i prefer mysql as my database . there are two most common ways to install mysql in your mac , First by using official DMG file Second by using homebrew .

install using homebrew

after installation open your .bashrc file or if you are using zsh then open .zshrc file

and add at the end ( for DMG installation )

for brew installation

2 . Installing RVM

before installing rvm optionally you can install gcc49

How To Download Ruby On Rails For Mac

after installation open your .bashrc file and add

How To Download Ruby On Rails For Mac High Sierra

they are COMMENTED out , UNCOMMENT that when you facing problem in installing gems ( like libv8 and therubyracer )

my .zshrc

now its time to install rvm

after installation quite terminal and open again and type

if installation was successful then you will get

otherwise try to troubleshoot your rvm installation . ( as your question in our forum )

3 . Installing Ruby

after installing rvm now lets install ruby

How To Download Ruby On Rails For Mac Os

after installation restart your terminal and type

you will get

it means now ruby is installed its time to install gems

4 . Installing Rails ( and other gems )

rails is a gem and installing gem is so easy just type

it will install all dependent gems as well

5 . Verifying installation

after installing gem type

(Related article: How to Install Ruby on Rails for Mac OSX Mavericks)

For this post we are based on a clean “Ubuntu 14.04 LTS” installation, nevertheless I have installed these tools in previous versions with the same steps. And similar steps should work in other Linux ditros.

For day to day Ruby on Rails development work we need several tools to be porperly installed and running:

  • Git: Right now this is the standard Version Control System in the industry. Even more!! I work with git in all my client projects since a few years ago.
  • Rbenv (and ruby): lightweight Ruby Version Manager to isolate Ruby versions and project dependencies.
  • Rails: Our favourite framework to build Web apps.
  • Sublime Text Editor: lightweight modern editor.
  • PostgreSQL: Probably the best Database in the open source market (in fact my favourite)

For Ubuntu my first recommendation, before to make a big installation, is updating system packages:

Step 1. Installing Git

Git is the standard VCS for the Ruby community, and probably for the IT industry at this moment. Also it is pretty simple to install at Ubuntu:

Git will need your email and name at least to identify your commits, but I have added some other configurations interesting for my day-to-day work. Execute each line in prompt:

Probably you will use Github to deliver code to your clients, and it will need to identify you through your ssh-keys. You can follow this guide in order to create ssh keys (if you do not have them yet) and configure your account.

This process is similar with other Git providers like Bitbucket or your Company owned Git servers.

Step 2. Dynamic prompt with Git and ANSI colors

How To Download Ruby On Rails On Mac

Tobias Sjösten wrote a pretty useful article explaining this.

This hack will:

  • Put our current branch in prompt
  • Change color if there are files to commit

This gives you a quick status of your changes in project in a quick eye-shot. You just have to add the following code to ~/.bash_profile file:

You should restart terminal for these changes to take effect.

Step 3. Install Ruby with RBENV

RVM and RBENV are the most used Ruby Version Managers among developers. Rbenv is lighter and solves the dependency isolation problem working with Bundle (the default dependency management gem for Rails).

RBENV give us several advantages:

  • The obvious ‘apt-get install ruby’ is outdated, and you probably want to work with latest ruby versions.
  • Allow different versions of ruby in the same machine, which will be useful when we write code in different projects.
  • Dependency isolation working with bundle.

You need Git that was installed previously to install RBENV.

With commands above you have installed Rbenv and the ruby versions builder, and give access to them directly from command prompt. Please, restart your terminal to load Rbenv.

The only disadvantage of BINSTUBS is that you have to remember to run the following command

Now, you can install every ruby version with a command:

Step 4. Your first Rails App

First you need to install Rails gem:

Create your new app:

Go to Gemfile and uncomment this line:

The gem “Therubyracer” is Google V8 engine wrapped in a gem, in order to have the capability of evaluating JavaScript code from Ruby. Pretty interesting in Rails templates and assets.

How To Download Ruby On Rails For Mac

After that re-install gems:

How To Download Ruby On Rails For Mac Mojave

And start it in your browser at http://localhost:3000

Step 5. Set Up Sublime Text as Code Editor

There are several code editors in the market to edit ruby code: SublimeText, RubyMine, Aptanta,…. Or Opensource like vim, gedit or emacs. Sublime Text is an excellent choice if you want a lightweight editor with great features and a modern user interface.

Download and unzip last version from the web page. In order to give access from command prompt:

Now you can open your Rails app by typing:

The convention for Ruby programs is to use two spaces as indentation. You can follow Sublime Text 2 => Preferences => Settings - User and add these lines.

Step 6. PostgreSQL installation

This is a pretty good Database and maybe this will be your Production relational database. So worth it to take a look at how to integrate it with rails:

You can add the gem to your Gemfile:

And run bundle again: bundle install, to make PG gem installation.

How to download ruby on rails for mac high sierra

After that your Database config file should be like:

Extra Ball. Set up RubyMine

Here at Tealeaf Academy we recommend Sublime for our students, because is lighter and easy to use. But if you need a more complete editor: with debugger, Git or Ticketing System integration, plugins … . RubyMine is a great choice.

You need a Java Runtime installation before:

Download and install:

They allow you a 30 day trial version, after that you should purchase a license.

Then you can open every Rails application within the project folder with the command:

Conclusion

Well, this is just the beginning. Here we just installed our Dev environment with a bunch of really useful tools, which you will use in your day-to-day work.

If you want a structured, instructor led program to level up to a professional level Ruby on Rails developer, check out our curriculum!