0% found this document useful (0 votes)
106 views

Setup Ruby On Rails Development Environment

The document provides instructions for setting up a Ruby on Rails development environment on Ubuntu 16.04 LTS. It includes steps to install Ruby, Rails, Git, Heroku Toolbelt, Sublime Text editor, and provides additional resources for learning Ruby on Rails, Git, MySQL, coding best practices and other tools.

Uploaded by

Le Quang Vu Ke
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views

Setup Ruby On Rails Development Environment

The document provides instructions for setting up a Ruby on Rails development environment on Ubuntu 16.04 LTS. It includes steps to install Ruby, Rails, Git, Heroku Toolbelt, Sublime Text editor, and provides additional resources for learning Ruby on Rails, Git, MySQL, coding best practices and other tools.

Uploaded by

Le Quang Vu Ke
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Training Guide

I - Set up Ruby on Rails Development Environment


Ubuntu 16.04 LTS
RVM - Ruby version manager
Ruby 2.3.1
Rails 5.0.1
Git
Heroku Toolbelt
Sublime Text 2 / 3

Open Terminal to setup for Sh


First change some settings in Gnome Terminal. Go to Edit -> Profile Preferences -> Title and
Command and check the Run Command as login shell box.

1. Install Ruby on Rails


Make sure all packages are up to date
sudo apt-get update

Install curl (if not have)


sudo apt-get install curl

And some dependencies for Ruby

sudo apt-get install zlib1g-dev build-essential libssl-dev


libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev
libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-
dev

Install rvm, ruby and set default version

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool


bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys
409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.3.1
rvm use 2.3.1 --default
ruby -v

Its time to install Rails 5.0.1 without ri and rdoc (which you actually never use)
gem install rails --version 5.0.1 --no-ri --no-rdoc
Running the following command to make sure Ruby on Rails has been installed successfully
rails new test
cd test
rails s

Open browser, visit: http://localhost:3000, if an web page is open then you are success.

Fix a problem that makes rails not found error:


https://rvm.io/integration/gnome-terminal

Since Rails ships with so many dependencies these days, we're going to need to install a
Javascript runtime like NodeJS. This lets you use Coffeescript and the Asset Pipeline in
Rails which combines and minifies your javascript to provide a faster production environment.

To install NodeJS, we're going to add it using the official repository:

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -


sudo apt-get install -y nodejs

2. Install Git

Create an account on Github @ https://github.com/

Install Git
sudo apt-get install git-core

Git basic config

git config --global color.ui true


git config --global user.name "Your Name"
git config --global user.email [email protected]

Your email should be the same as your Github account. You may set it differently, but it will
introduce some additional work.

You should use ssh-key to authentication each time you pull from or push to Github.

ssh-keygen -t rsa -b 4096 -C "[email protected]"

The next step is to take the newly generated SSH key and add it to your Github account. You
want to copy and paste the output of the following command and paste it here.

cat ~/.ssh/id_rsa.pub

Once you've done this, you can check and see if it worked:

ssh -T [email protected]
You should get a message like this:

Hi excid3! You've successfully authenticated, but GitHub does not


provide shell access.

3. Install Heroku Toolbelt


Create an account on Heroku @ https://www.heroku.com/

Install Heroku Toolbelt follow the instruction at https://toolbelt.heroku.com/

After successfully install Heroku Toolbelt, run the following command:


heroku login

4. Install Sublime Text 2/3


For sublime text 2

sudo add-apt-repository ppa:webupd8team/sublime-text-2


sudo apt-get update
sudo apt-get install sublime-text

For sublime text 3

sudo add-apt-repository ppa:webupd8team/sublime-text-3


sudo apt-get update
sudo apt-get install sublime-text-installer

You can launch Sublime Text 2 from Terminal by typing subl

II - Learn Ruby on Rails


1. Ruby on Rails tutorials
Ruby on Rails Tutorial: http://ruby.railstutorial.org/

Good References:
http://guides.rubyonrails.org/
http://api.rubyonrails.org/
http://google.com

2. Rails & RESTful


Basic about RESTful Web services
http://www.ibm.com/developerworks/vn/library/ws-restful/
References
Representational State Transfer (REST):
http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
RESTful Web Services book
http://shop.oreilly.com/product/9780596529260.do

le3. Working with form

III - Learn Git


1.

Pro Git book: http://git-scm.com/book

Slide: https://goo.gl/luILrq

2. Framgia pull-req procedure (True way)

1. Before working on a new task


git checkout develop
git pull framgia develop
2. Create a new branch for the task
git checkout -b task-name
3. When ready for commit
git add .
git commit -m descriptive message about this commit
4. Checkout to the develop branch to pull newest code
git checkout develop
git pull framgia develop
5. Return to the working branch and rebase
git checkout task-name
git rebase develop
6. If there are conflicts, go to conflict files and fix them, after finish, continue rebase
git add .
git rebase --continue
7. Push the commit to Github account
git push origin task-name

IV - MySQL
sudo apt-get install mysql-server mysql-client libmysqlclient-dev

Installing the libmysqlclient-dev gives you the necessary files to compile the mysql2 gem which
is what Rails will use to connect to MySQL when you setup your Rails app.
Learning MySQL: http://student.agh.edu.pl/~gegotek/Learning%20MySQL%20V413HAV.pdf
Introduction to SQL: http://cs.lmu.edu/~ray/notes/introsql/
No SQL: http://cs.lmu.edu/~ray/notes/nosql/

V - Coding Convention - Best Practices


Basic rules that you should follow in first place

80 chars rule (except view files)


do not use () as possible

Links to Framgia Coding standard:

Ruby
https://github.com/framgia/coding-standards/blob/master/vn/ruby/standard.md

Ruby on Rails
https://github.com/framgia/coding-standards/blob/master/vn/rails/standard.md

VI - Others
Install Memcached
sudo apt-get install memcached

Install ImageMagick
sudo apt-get install imagemagick

Install Redis
http://redis.io/download

Devise gem
http://devise.plataformatec.com.br/

Simple example
https://github.com/jayshepherd/devise_example

Install Node.js
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#ubuntu-mint

How to Setup a Production Server for Rails 4


http://robmclarty.com/blog/how-to-setup-a-production-server-for-rails-4

You might also like