Ruby On Rails Install For Mac

Posted on by

RVM supports most UNIX like systems and Windows (with Cygwin or Bash on Ubuntu on Windows). The basic requirements are bash, curl, gpg2 and overall GNU version of tools - but RVM tries to autodetect it and install anything that is needed.

∞Install GPG keys

Ruby on rails install for macbook pro

As a first step install GPG keys used to verify installation package:

In case you encounter an issues check security

A number of tools exist to help you quickly install Ruby and Ruby on Rails on your system. Windows users can use Rails Installer, while Mac OS X users can use Tokaido. For more installation methods for most Operating Systems take a look at ruby-lang.org. Once Homebrew is installed, you can use it to install Ruby. Brew install ruby This will install the latest Ruby version on Homebrew (which is 2.5.0 at the time of this writing) on /usr/local/bin/ruby. Add /usr/local/bin to the start of your PATH so it becomes the default Ruby. Get Ruby on Rails in no time Rails is low on dependencies and prides itself on shipping with most everything you need in the box. To get started, just install Ruby, the language, and RubyGems, the package manager. We recommend Ruby 2.2 or newer for use with Rails. Rails requires Ruby 1.9.3. Ruby on Rails is a popular application stack for developers looking to create sites and web apps. The Ruby programming language, combined with the Rails development framework, makes app development quick and efficient. One way to install Ruby and Rails is with the command-line tool rbenv. Using rbenv will provide you with a well-controlled. In case you can't use the Rails development box, see the steps below to manually build a development box for Ruby on Rails core development. 2.1 Install Git. Ruby on Rails uses Git for source code control. The Git homepage has installation instructions. There are a variety of resources on the net that will help you get familiar with Git.

∞Basic install

∞Ubuntu

RVM have dedicated Ubuntu package, so please follow instructions posted here: https://github.com/rvm/ubuntu_rvm

If you need a different (newer) version of RVM, after installing base version of RVM check the Upgrading section.

∞Any other system

Install RVM (development version):

Install RVM stable with ruby:

Additionally with rails (poor man's railsinstaller):

Or with jruby, rails and puma:

To install without rubygems-bundler and rvm gems (and also remove those gems from both global.gems and default.gems):

To install with hirb gem (and also add it to global.gems):

To install with rails and haml gems (and also add them to default.gems):

Without autolibs:

For a progress bar when downloading RVM / Rubies:

Point to be noted is, there is a backslash before curl. This prevents misbehaving if you have aliased it with configuration in your ~/.curlrc file.

Download it now for free.Requires Mac OS X 10.2 or higher(15 MB)Aquaria is a stunning underwater adventure game. Explore a variety of strange and wonderful environments as you discover the secrets of Aquaria, learn new powers and fight the evils of the deep.Requires Mac OS X 10.3 or higherBraid is a beautiful platform game where you manipulate the flow of time to solve puzzles. For mac game free download. It's fast to play, it has awesome graphics, it comes with a variety of maps, and you can play multiplayer games easily! This game will provide you with hours and hours of fun. They are fun to play, and you can download them for free!!!Updated in 2010 with some of the newest fun cool mac games.Lux Delux is a superb Mac OS X version of the board game Risk.

If you're an existing RVM user and you don't want RVM to attempt to setup your shell to load RVM, you can opt out of this at install time by exporting rvm_ignore_dotfiles=yes, or opt out permanently by setting this in your rvmrc.

∞You can also:

  • read the installation documentation below.
  • watch the most accurate (but not official) rvm screencast.
  • read the most accurate (but not official) rvm cheat sheet.
  • starting with Rails? watch the RailsCasts.com on Getting Started with Rails.

∞Installation explained

There are three different ways to install and configure RVM.

  1. Single-User installations (recommended) - For an isolated install within a user's $HOME, not for root.
  2. Multi-User installations - For server administrators - For an installation usable by all users on the system - Please note that Single-User supersedes Multi-User. This also used to be called the System-Wide Install. Using this type of installation without knowledge how umask works is a big security risk.
  3. Mixed mode installations - For an installation usable by all users on the system - with isolated rubies/gemsets within a user's $HOME. Installation instructions are exactly the same as for Multi-User installations, the difference is in users environment.

get.rvm.io is a redirect to https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer You could also use full path for the installer:

∞Installation

I recommend you read the installation script yourself. This will give you a chance to understand what it is doing before installing, and allow you to feel more comfortable running it if you do so.

∞1. Download and run the RVM installation script

Installing the stable release version:

To get the latest development state:

Instruct RVM to not change the shell initializations files 'rc' / 'profile':

Please note that from this point it is user responsibility to add sourcing rvm to appropriate files.

For a Multi-User install you would execute the following:

Note: The Multi-User install instructions must be prefixed with the sudo command. However, once the install is complete, and the instructions to add users to the rvm group is followed, the use of either sudo or rvmsudo is no longer required. The sudo command is only to temporarily elevate privileges so the installer can complete its work. If you need to use sudo or rvmsudo after the install is complete, some part of the install directions were not properly followed. This usually is because people execute the install asroot, rather than executing the installation instructions from a non-privileged user account.

Installing a specific version:

Prefix the 'bash' portion with 'sudo', of course, if you wish to apply this to a Multi_user Install. Please feel free to check out our upgrading docs for more details on branch format.

Debugging installation process:

If the rvm install script complains about certificates you need to follow the displayed instructions.

Single-User Install Location: ~/.rvm/

If the install script is run as a standard, non-root user, RVM will install into the current users's home directory.

Modification of user configuration files (*rc / *profile) - RVM by default will modify user startup files, although it is not recommended you can disable automated process and do this manually:

Multi-User Install Location: /usr/local/rvm

If the install script is run prefixed with sudo, RVM will automatically install into /usr/local/rvm. Please see the troubleshooting page for an important note regarding Multi-User Installs.

Please see the FAQ page for an important note regardingroot only installs.

External tutorials

Note that that any outside tutorials are NOT supported whether they work or not. Tutorials are great, however we have spent massive amounts of man hours debugging the installation process. Please use the install process(es) from this site only, as this is the only supported installation types and methods.

To update an existing RVM installation

It is safe to simply re-run the installation script again, or you can follow the upgrading docs.

∞2. Load RVM into your shell sessions as a function

Single-User:

The rvm function will be automatically configured for every user on the system if you install as single user. Read the output of installer to check which files were modified.

Multi-User:

The rvm function will be automatically configured for every user on the system if you install with sudo. This is accomplished by loading /etc/profile.d/rvm.sh on login. Most Linux distributions default to parsing /etc/profile which contains the logic to load all files residing in the /etc/profile.d/ directory. Once you have added the users you want to be able to use RVM to the rvm group, those users MUST log out and back in to gain rvm group membership because group memberships are only evaluated by the operating system at initial login time. Zsh not always sources /etc/profile so you might need to add this in /etc/**/zprofile:

Mixed mode (user gemsets):

  • After following above instructions for Multi-User.
  • Select a user as a manager - he will be responsible for installing new rubies. This user should never run the command introduced below. If this happens, remove/rename the ${HOME}/.rvmrc, logout and then relogin. Otherwise you won't be able to install/upgrade new rubies correctly.
  • For each user that want to use RVM, an additional command needs to be run (once) for each user:

Gemsets created by these users will be hosted in their HOME directory. It's not possible to use global gemsets from system without using tricks like manually linking directories and they should not be used in mixed-mode. Please bear in mind that 'system' in this context does not refer to your distribution's ruby packages, but to the RVM Multi-User installation.

You have two possibilities to manage RVM. The first one is to add managers to the rvm group. The second one is to use separate managers with rvmsudo and privilege escalation. Note that it is not safe to use rvmsudo from mixed mode user. Both can be mixed without any side-effect. It is however very important to not enable mixed-mode gemsets or rubies for the managers. RVM is using a custom umask (umask u=rwx,g=rwx,o=rx) when installing gemsets, rubies, updating itself, etc. This should not impact your system. But if you prefer to avoid RVM messing around with your umask, you can comment the umask line in /etc/rvmrc.

This mode should also works with passenger, please follow passenger instructions. .

∞3. Reload shell configuration & test

Close out your current shell or terminal session and open a new one (preferred). You may load RVM with the following command:

If installation and configuration were successful, RVM should now load whenever you open a new shell. This can be tested by executing the following command which should output rvm is a function as shown below.

NOTE: Before reporting problems check rvm notes as it might contain important information.

Congratulations! You have successfully installed RVM.

∞Try out your new RVM installation

Below are some examples of how to install and use a Ruby under RVM.

Display a list of all known rubies. NOTE: RVM can install many more Rubies not listed.

Install a version of Ruby (eg 2.1.1):

Use the newly installed Ruby:

Check this worked correctly:

Optionally, you can set a version of Ruby to use as the default for new shells. Note that this overrides the 'system' ruby:

∞Enjoy using RVM!

∞Where to now?

If you are new to RVM I recommend that you read the basics page. At the end of the basics page there are further links for getting started.

∞Troubleshooting Your Install

  • When you run

    and got the notice

    ca-certificates need to be installed:

  • If you open a new shell and running:

    does not show rvm is a function, RVM isn't being sourced correctly.

  • Ensure that RVM is sourced after any path settings as RVM manipulates the path. If you don't do this, RVM may not work as expected.

  • If you are using GNOME on Red Hat, CentOS or Fedora, ensure that the Run command as login shell option is checked under the Title and Command tab in Profile Preferences. After changing this setting, you may need to exit your console session and start a new one before the changes take affect.

by Daniel Kehoe

See the author's blog at danielkehoe.com

Last updated 16 May 2020

This is an article from the RailsApps project. The RailsApps project provides Rails Example Applications that developers use as starter apps.

Install Ruby on Rails 6.0 on macOS 10.15 Catalina. Up-to-date and detailed instructions, plus troubleshooting, for the Rails newest release. How to set up and install Rails 6.0, the newest version of Rails, on macOS 10.15 Catalina.

The most complete and up-to-date installation guide for Ruby on Rails on macOS and a favorite of Rails developers. It explains how to set up a development environment for Rails, the same used by any professional Rails developer.

If You Are New to Rails

To use Rails on macOS, you'll need Ruby (an interpreter for the Ruby programming language) plus gems (software libraries) containing the Rails web application development framework. If you're new to Rails, see What is Ruby on Rails? or get the free book Learn Ruby on Rails.

Ruby Version Managers

You may hear about one-click installation programs such as RailsInstaller, Cinderella, and BitNami RubyStack. These installation programs are often outdated. Most developers install from scratch.

MacOS comes with a 'system Ruby' pre-installed. MacOS Catalina includes Ruby 2.6.3 which is not the newest version. Do not use the system Ruby (see an article for why). You should install a Ruby version manager and update to the newest Ruby version. You'll find instructions below.

Use Chruby to switch between Ruby versions. Some developers prefer RVM or rbenv but I now recommend Chruby.

A Ruby version manager makes it easy to switch between Ruby versions. I recommend Chruby. RVM was popular in the past but its additional features (its gemsets) are no longer necessary and it adds unnecessary complexity. Sam Stephenson's rbenv is also popular, but requires extra steps (the rehash command) and modifies gems when you install them.

Even if you are a student only building new Rails applications, you should be prepared to manage multiple versions of Ruby. In the future, you will need to install newer Ruby versions as they are released. And if you maintain older Rails applications, you will need a Ruby version manager.

You'll need to prepare your computer before installing Ruby on Rails.

Ruby On Rails Install For Macos

Prepare Your Computer

A Hosted Development Alternative

You can use Ruby on Rails without actually installing it on your computer. Hosted development, using a service such as AWS Cloud9, means you get a computer 'in the cloud' that you use from your web browser. Any computer can access the hosted development environment, though you'll need a broadband connection. Cloud9 is free for small projects.

Using a hosted environment means you are no longer dependent on the physical presence of a computer that stores all your files. If your computer crashes or is stolen, you can continue to use your hosted environment from any other computer. Likewise, if you frequently work on more than one computer, a hosted environment eliminates the difficulty of maintaining duplicate development environments. However, most developers set up a local developmemt environment on their own computer.

These instructions are for macOS Catalina 10.15.

If You Updated to macOS Catalina

If you updated to Catalina from an earlier version of macOS (sometimes called an 'over the top' installation), and you previously installed a Rails development environment, your earlier installation remains intact. You will need to install the new version of Xcode Command Line Tools (full instructions below). Though Rails is still intact after an update, read through this article and take this opportunity to update your development environment.

Upgrade macOS to Catalina

MacOS Catalina was released on October 7, 2019. Make sure you have the latest version of macOS. Under the Apple menu, check 'About This Mac.' It should show 'Version 10.15.0' or newer. If you've owned your Mac for several years and haven't updated macOS, be prepared to spend several hours updating the operating system.

If you need to upgrade, see Apple's instructions Upgrade to macOS Catalina. You can install macOS 10.15 (Catalina) from the Mac App Store for free. Allow plenty of time for the download and installation (it may take several hours).

If you've already done development on earlier Mac versions, be aware of these changes in Catalina:

  • Catalina uses Zsh as a default shell instead of Bash. You'll set configurations (such as PATH and aliases) in the .zshrc file.
  • Apple has removed the /usr/include folder making it difficult to compile some older system tools.

Terminal Application (for Beginners)

To learn more about Unix shell commands, read The Command Line Crash Course or Learn Enough Command Line to Be Dangerous.

You'll need to use the Terminal application to install Ruby and develop Rails applications. The Terminal application or console gives us access to the Unix command line, or shell. We call the command line the shell because it is the outer layer of the operating system's internal mechanisms (which we call the kernel). Search for the macOS Terminal application by pressing the Command-Spacebar combination (which Apple calls 'Spotlight Search') and searching for 'Terminal.' Or look in the Applications/Utilities/ folder for the Terminal application.

You'll also need a text editor (typically VS Code or Atom) to configure your Mac (and for writing code).

Launch the Terminal application. Then try out the terminal application by entering a shell command:

$ whoami

Don't type the $ character. The $ character is a cue that you should enter a shell command. This is a longtime convention that indicates you should enter a command in the terminal application. The Unix shell command whoami returns your username.

Just a reminder to absolute beginners: Press 'Enter' after you type the command.

Is Xcode Already Installed?

You need to install Apple's Xcode Command Line Tools to get the Unix tools needed to install Ruby and develop with Rails. Xcode is Apple's software library for macOS developers. You don't need all of Xcode for Rails development. You just need the Xcode Command Line Tools. Only install the full Xcode package if you are doing development of applications for the Apple operating systems.

Check if you have previously installed the full Xcode package:

$ xcode-select -p

Scenario 1

If you see:

xcode-select: error: unable to get active developer directory..

The Xcode package is not installed. Jump to the next section and install only the Xcode Command Line Tools.

Scenario 2

If you see:

/Applications/Xcode.app/Contents/Developer

The full Xcode package is already installed. Perhaps you installed it previously. If Xcode is installed, you will need to update Xcode to the newest version (Xcode 11 or newer). Go to the App Store application and check 'Updates.' After updating Xcode, be sure to launch the Xcode application and accept the Apple license terms.

Scenario 3

If you see:

/Library/Developer/CommandLineTools

The Xcode Command Line Tools may be installed or an older version is installed. Here's how to test:

$ /usr/sbin/pkgutil --packages grep CL

You should see:

com.apple.pkg.CLTools_Executables

Also try:

/usr/sbin/pkgutil --pkg-info com.apple.pkg.CLTools_Executables

You should see:

package-id: com.apple.pkg.CLTools_Executables

If you get a response from the test, you're done. The Xcode Command Line Tools are installed and you can skip ahead to install Homebrew.

If you get no response from the test, you have an older version of Xcode Command Line Tools and you must remove it.

Remove the old version:

$ sudo rm -rf /Library/Developer/CommandLineTools

Install rails mac

You are using sudo for admin access so you must enter the password you use to log in to your computer (you will not see the password after entering it). After removing the old version, jump to the next section and install the Xcode Command Line Tools.

Scenario 4

If you see a file location that contains spaces in the path:

/Applications/Apple Dev Tools/Xcode.app/Contents/Developer

you will have problems installing Ruby. You should delete and reinstall Xcode.

Install Xcode Command Line Tools

The Xcode Command Line Tools provide a C language compiler needed to install Ruby. For many Rails projects, you will need the C language compiler to install gems that use native extensions (such as Nokogiri).

Here's how to install Apple's Xcode Command Line Tools.

MacOS Catalina will alert you when you enter a command in the terminal that requires Xcode Command Line Tools. For example, you can enter gcc, git, or make.

Try it. Enter:

$ gcc

If Xcode Command Line Tools are not installed, you'll see an alert box:

Alternatively, you can use a command to install Xcode Command Line Tools. It will produce a similar alert box. Note the double hyphen:

$ xcode-select --install

Click 'Install' to download and install Xcode Command Line Tools. If you have a slow Internet connection, it may take many minutes.

If the download takes a very long time (over an hour) or fails, you can try an alternative. Go to https://developer.apple.com/downloads/more and enter your Apple ID and password. You'll see a list of software packages you can download. Look for the latest version of Command Line Tools and click to download the .dmg file. Downloading the .dmg file is much faster than waiting for the command-line-based download. Install the .dmg file by clicking on the package icon. You'll need about 1.46GB of storage on your computer.

Verify that you've successfully installed Xcode Command Line Tools.

$ xcode-select -p

You should see:

/Library/Developer/CommandLineTools

The Xcode Command Line Tools must be installed before you go to the next steps. Just to be certain, verify that the Command Line Tools executables are available:

$ /usr/sbin/pkgutil --packages grep CL

You should see:

com.apple.pkg.CLTools_Executables

Also try:

/usr/sbin/pkgutil --pkg-info com.apple.pkg.CLTools_Executables

You should see:

package-id: com.apple.pkg.CLTools_Executables

If the Command Line Tools executables are available, you'll have no problem compiling Nokogiri or any other gems that require native extensions.

Install Homebrew

Developers use Homebrew to install various Unix software packages, including chruby and ruby-install.

If you did not use a password to log in to your Mac (that is, if your password is blank), you cannot install Homebrew.

$ brew

Check if Homebrew is installed.

If Homebrew is not installed, install it.

$ /bin/bash -c '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)'

The Homebrew installation script will ask you to enter your Mac password.

Password:

The Homebrew installation script may display a warning:

WARNING: Improper use of the sudo command could lead to data loss..

Ruby On Rails Install Mac

To proceed, enter your password..

Ignore the scary warning and enter your Mac password. You won't see the characters as you type. Press enter when you are done.

If you've installed Homebrew, you can check that Homebrew is installed properly.

$ brew doctor

Next we'll configure Git, an essential tool for any developer.

Configure Git

Before installing Ruby on Rails, you should configure Git. Git is automatically installed as part of the Xcode Command Line Tools.

Git provides a source control repository. Developers use Git to roll back code changes when needed, to collaborate with others, and deploy applications for hosting with a service such as Heroku. As a Rails developer, you'll use Git with a GitHub account for remote backup and collaboration. See the article Rails with Git and GitHub for more background.

Before you configure Git, it is a good idea to create an account on GitHub. It is important to use the same email address for Git and for GitHub. After you create an account on GitHub, follow their instructions to set up an SSH key so you don't have to enter a username and password every time you connect to GitHub from the Terminal.

Check that Git is installed:

$ git version

You should see git version 2.21.1 (or newer).

If the Git version installed with Xcode Command Line Tools is old, you can use Homebrew to install the latest version of Git:

$ brew install git

You can use Homebrew to upgrade to the newest version of Git:

$ brew upgrade git

Configure Git if you haven't used it before. First, list the current settings with the git config -l --global command. Then set user.name and user.email if necessary. Don't just copy and paste the code you see here. Edit it to add your name and the email address you've used for GitHub.

Now you'll be ready to use Git when you need it.

Install Ruby-install and Chruby

Use Homebrew to install the ruby-install utility and the chruby Ruby version manager.

$ brew install ruby-install chruby

You'll see beer mug emojis (part of the Emoji 1.0 standard released in 2015).

Configure Chruby

You must update your Unix .zshrc file so that the chruby program can be found.

The .zshrc file is in your user home folder. It is hidden in the file browser. You can enter Command + Shift + . to show hidden files. If you want to hide those files again, you can enter the same keystrokes.

You can force the Mac to always display hidden files by entering the following command in the Terminal application:

$ defaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder

Hidden files will appear in gray in the Finder window.

Use your text editor (typically VS Codeor Atom) to open the .zshrc file. Check the instructions for your text editor to learn how to open files from the terminal. In VS Code, open the Command Palette (⇧⌘P) and type 'shell command' to locate and click 'Shell Command: Install 'code' command in PATH command.'

To open the .zshrc file with VS Code:

$ code ~/.zshrc

In Unix, the squiggle (tilde) character is a shortcut to your user home folder.

Add two lines anywhere in your .zshrc file. Your .zshrc file may not exist (or may be empty) if you have not used it before. Saving the file will create it.

source /usr/local/share/chruby/chruby.sh

source /usr/local/share/chruby/auto.sh

The first line makes the chruby program available in the shell. The second line will automatically switch the current version of Ruby when you change directories if a hidden file indicates a specific Ruby version.

You must close and reopen the Terminal window for the changes to the .zshrc file to be recognized.

Check that each program was installed successfully.

$ ruby-install -V

$ chruby -h

Now you can install the newest Ruby version.

Install Ruby

After installing the ruby-install utility, install the newest version of Ruby.

The Chruby version manager will use your shell to intercept any calls to Ruby. There's no need to remove the system Ruby. The system Ruby will remain on your system and your preferred version will take precedence.

You can check for the current recommended version of Ruby. Tell the ruby-install utility to check for the newest Ruby version.

$ ruby-install --latest

Then install the newest Ruby version.

$ ruby-install --latest ruby

Add a line to the .zshrc file to set the new Ruby version as a default.

chruby ruby-2.7.0

You'll need to close and re-open the terminal window.

Then verify that the newest version of Ruby is installed:

$ ruby -v

Now you can update the development environment. It is likely some gems have been updated since the newest version of Ruby was released. It's best if everything is up to date before you start a new project.

Check the Gem Manager

RubyGems is the package manager in Ruby. We use it to install software packages that add functionality to Ruby.

Check the installed gem manager version.

$ gem -v

You can check if a newer RubyGems version is available. Use gem update --system to upgrade the Ruby gem manager:

$ gem update --system

Faster Gem Installation

By default, when you install gems, documentation files will be installed. Developers seldom use gem documentation files (they'll browse the web instead). Installing gem documentation files takes time, so many developers like to toggle the default so no documentation is installed.

Here's how to speed up gem installation by disabling the documentation step:

$ echo 'gem: --no-document' >> ~/.gemrc

This adds the line gem: --no-document to the hidden .gemrc file in your home directory.

Install Nokogiri

Nokogiri is a gem that is a dependency for many other gems. Nokogiri is a gem that requires compilation for your specific operating system. As such, if your system environment doesn't match Nokogiri's requirements, compilation of Nokogiri will fail. If your system is configured properly, you'll be able to compile Nokogiri. However, compilation takes time. Every time you install the Nokogiri gem, you'll wait (as long as five minutes).

To save time, install the Nokogiri gem:

$ gem install nokogiri

During installation, Nokogiri will display two lengthy messages in the console. It will also pause without displaying any progress for as long as five minutes. Don't assume installation has failed unless you see an error message or you've waited more than ten minutes.

If Nokogiri installation fails, it's likely your Xcode Command Line Tools are not installed correctly. Try installing the Xcode Command Line Tools from the Apple developer site, as described above in the section 'Install Xcode Command Line Tools.' The maintainers of the node-gyp build tool have provided Installation notes for macOS Catalina that are very helpful in resolving Xcode Command Line Tools installation issues. The Nokogiri maintainers also provide instructions for Installing Nokogiri.

Install Rails

Check for the current version of Rails. Rails 6.0.2 was current when this was written.

You can install Rails into the current Ruby environment.

Here are the options you have for installing Rails.

If you want to install the current stable release:

$ gem install rails

If you want the newest beta version or release candidate, you can install with --pre.

$ gem install rails --pre

Or you can get a specific version.

For example, if you want the Rails 5.2.3 release:

How To Install Rails

$ gem install rails --version=5.2.3

Verify that the correct version of Rails is installed:

$ rails -v

Rails 6.0.2

Rails is now installed. If you want, you can close the Terminal window. Everything is installed, so you won't lose anything by closing the Terminal.

Next, try building a Rails application.

Create a Workspace Folder

You'll need a convenient folder to store your Rails projects. You can give it any name, such as code/ or projects/. For this tutorial, we'll call it workspace/.

Create a projects folder and move into the folder:

$ mkdir workspace

$ cd workspace

This is where you'll create your Rails applications.

New Rails Application

Here's how to create a new Rails application.

$ rails new myapp

We'll name the new application 'myapp.' Obviously, you can give it any name you like.

The rails new command generates the default Rails starter app.

Quick Test

For a 'smoke test' to see if everything runs, display a list of Rake tasks.

$ cd myapp

$ rails -T

Run the application with the Rails server command:

$ rails server

Use your web browser to visit the application at http://localhost:3000/.

Use Control-c to stop the server.

This concludes the instructions for installing Ruby and Rails. Read on for additional advice and tips.

Terminal Application and Text Editor

The built-in Apple Terminal application is adequate but many developers install iTerm 2. It has more options for customization.

For examining and writing code, you'll also need a text editor program such as VS Code or Atom. Of course, some programmers will suggest you try Vim or Emacs.

Databases for Rails

Rails uses the SQLite database by default. MacOS come with SQLite pre-installed and there's nothing to configure.

Though SQLite is adequate for development (and even some production applications), a new Rails application can be configured for other databases. The command rails new myapp --database= will show you a list of supported databases.

Supported for preconfiguration are: mysql, oracle, postgresql, sqlite3, frontbase, ibm_db, sqlserver, jdbcmysql, jdbcsqlite3, jdbcpostgresql, jdbc.

PostgreSQL

Use the easy-to-install macOS Postgres.app if you'd like to use PostgreSQL.

To create a new Rails application to use PostgreSQL:

$ rails new myapp --database=postgresql

The --database=postgresql parameter will add the pg database adapter gem to the Gemfile and create a suitable config/database.yml file.

Deployment

Most developers deploy their applications with a 'platform as a service' (PaaS) provider such as Heroku.

See a helpful comparison of Rails hosting services.

For deployment on Heroku, see the article:

Security

By design, Rails encourages practices that avoid common web application vulnerabilities. The Rails security team actively investigates and patches vulnerabilities. If you use the most current version of Rails, you will be protected from known vulnerabilities. See the Ruby On Rails Security Guide for an overview of potential issues and watch the Ruby on Rails Security Mailing List for announcements and discussion.

Your Application's Secret Token

Rails uses a session store to provide persistence between page requests. The default session store uses cookies. To prevent decoding of cookie data and hijacking a session, Rails encrypts cookie data using a secret key. When you create a new Rails application using the rails new command, a unique secret key is generated.

The file config/master.key contains a secret token used to decrypt credentials (and other encrypted files).

Take care to hide the secret token you use in production. Don't expose it in a public GitHub repo, or people could change their session information, and potentially access your site without permission. It's best to set the secret token in a Unix shell variable.

If you need to create a new secret token:

$ rails secret

The command rake secret generates a new random secret you can use. The command won't install the key; you have to copy the key from the console output to the appropriate file.

Troubleshooting

Conflicting Bundler Versions

If you install a version of Bundler that is newer than the default installed with Ruby, you will get a message 'Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4)' when you run a Rails command. You can avoid the warning by prepending bundle exec, for example bundle exec rails -T. It's not possible to remove a default gem with gem uninstall bundler so it's advisable not to install a newer version of Bundler unless absolutely necesary.

Ruby On Rails Install For Macbook Pro

Problems with 'Gem::RemoteFetcher::FetchError: SSL_connect'

Ruby and RubyGems (starting with Ruby 1.9.3p194 and RubyGems 1.8.23) require verification of server SSL certificates when Ruby makes an Internet connection via https. If you run rails new and get an error 'Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate' see this article suggesting solutions: OpenSSL errors and Rails.

Problems with 'Certificate Verify Failed'

Are you getting an error 'OpenSSL certificate verify failed' when you try to generate a new Rails app from an application template? See this article suggesting solutions: OpenSSL errors and Rails.

Ruby On Rails Windows

Installing in a Second Account

If you've created a second user account on your Mac, and the first user has already installed Homebrew, the first user may have to change permissions for the /usr/local/bin and /usr/local/Cellar folders:

Download free photoshop for mac full version

$ sudo chmod g+w /usr/local/bin

$ sudo chmod g+w /usr/local/Cellar

The second user account should be given admin privileges using the System Preferences 'Users and Groups' setting.

Where to Get Help

Your best source for online help with problems is Stack Overflow. Your issue may have been encountered and addressed by others.

To find a real person who can help, attend a Ruby meetup in your city. Google for 'ruby meetup' with your city name.

Have a problem with Ruby on Rails installation? Got a suggestion for others?