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://[Link] --recv-keys
409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL [Link] | 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: [Link] if an web page is open then you are success.
Fix a problem that makes rails not found error:
[Link]
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 [Link] | sudo -E bash -
sudo apt-get install -y nodejs
2. Install Git
Create an account on Github @ [Link]
Install Git
sudo apt-get install git-core
Git basic config
git config --global [Link] true
git config --global [Link] "Your Name"
git config --global [Link] newuser@[Link]
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 "YOUR@[Link]"
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 git@[Link]
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 @ [Link]
Install Heroku Toolbelt follow the instruction at [Link]
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: [Link]
Good References:
[Link]
[Link]
[Link]
2. Rails & RESTful
Basic about RESTful Web services
[Link]
References
Representational State Transfer (REST):
[Link]
RESTful Web Services book
[Link]
le3. Working with form
III - Learn Git
1.
Pro Git book: [Link]
Slide: [Link]
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: [Link]
Introduction to SQL: [Link]
No SQL: [Link]
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
[Link]
Ruby on Rails
[Link]
VI - Others
Install Memcached
sudo apt-get install memcached
Install ImageMagick
sudo apt-get install imagemagick
Install Redis
[Link]
Devise gem
[Link]
Simple example
[Link]
Install [Link]
[Link]
How to Setup a Production Server for Rails 4
[Link]