Developer will install web application Ruby On Rails framework. Ruby On Rails can installed at Windows, Linux and macOS, Let’s following this.
Install Ruby On Rails at Windows
1. Check Ruby Version
First, you must check if ruby is already installed or not, if it is doesn’t exist, you can continue to install fresh Ruby installation.
2. Install Ruby
You can download an installation package from rubyinstaller.org. Follow the download link and run the resulting installer.
3. Install Rails
You can install all of rails using the following command through the command line
C:> gem install rails
4. Check Rails Version
You must following command check the rails version.
C:> rails -v
And if the output is something like Rails 4.2.4, you are success!
Install Ruby on Rails at Linux
In Linux we are can installing Ruby On Rails using rbenv. rbenv can provides an easy installation procedure to manage varous version of Ruby.
1. Install Prerequites Dependecies
You must install git-core to install Ruby On Rails. Use the following command for installing Rails using yum.
sudo yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
2. Install rbenv
Now we will install rbenv and set the appropriate environment variables. Use the following set of commands to get rbenv for git repository.
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH = "$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH = "$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' << ~/.bash_profile
3. Install Ruby
We will install Ruby 2.2.3. Use the following command for installing Ruby.
rbenv install -v 2.2.3
Use the following command for setting up the current Ruby version as default.
rbenv global 2.2.3
Use the following command to verify the Ruby version.
ruby 2.2.3p173 (2015-08-18 revivion 51636) [X86_64-linux]
keyword gem for installing the supported dependencies.
4. Install Rails
Use the following command for installing Rails version 4.2.4.
install rails -v 4.2.4
Use the following command to make Rails executable available.
Use the following command for checking the rails version.
We will take Node.js from EPEL yum repository. Use the following command to add the EPEL package to the yum repository.
sudo yum -y install epel-release
Use the following command for installing the Node.js package.
sudo yum install nodejs
6. Install Database
By default, Rails uses sqlite3, but you may want to install MySQL, PostgreSQL, or other RDBMS. This is optional; if you have the database installed, then you may skip this step and it is not mandatory that you have a database installed to start the rails server. For this tutorial, we are using PostgreSQL database. Therefore use the following commands to install PostgreSQL.
sudo yum install postgresql-server postgresql-contrib
Accept the prompt, by responding with a y. Use the following command to create a PostgreSQl database cluster.
sudo postgresql-setup initdb
Use the following command to start and enable PostgreSQL.
sudo systemctl start postgresql
sudo systemctl enable postgresql
Keeping Rails Up-to-Date
Assuming you have installed Rails using RubyGems, keeping it up-to-date is relatively easy. We can use the same command in both Windows and Linux platform. Use the following command :
gem update rails
The following screenshot shows a Windows command prompt. The Linux terminal also provides the same output.
This will automatically update your Rails installation. The next time you restart your application, it will pick up this latest version of Rails. While using this command, make sure you are connected to the internet.
You can verify if everything is set up according to your requirements or not. Use the following command to create a demo project.
rails new demo
Rails New Demo
It will generate a demo rail project; we will discuss about it later. Currently we have to check if the environment is set up or not. Next, use the following command to run WEBrick web server on your machine.
It will generate auto-code to start the server Rails Server
Now open your browser and type the following http://localhost:3000
That was about how to install ruby on rails, and if you know about how to install some framework, you can visit at www.41studio.com/blog and coment below.