Skip to content

Instantly share code, notes, and snippets.

@cuonggt
Last active September 17, 2015 03:19
Show Gist options
  • Save cuonggt/e1a63df1fcf957990547 to your computer and use it in GitHub Desktop.
Save cuonggt/e1a63df1fcf957990547 to your computer and use it in GitHub Desktop.
A guide to setting up a Ruby on Rails development environment

Cài đặt Ruby On Rails trên Mac OS X 10.10 Yosemite

Cài rbenv

Có 2 công cụ phổ biến để cài đặt và quản lý các phiên bản Ruby là rbenvrvm. Chúng ta sẽ sử dụng rbenv. Để cài đặt, chạy các lệnh sau trên Terminal:

brew install rbenv ruby-build
# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

Cài Ruby

rbenv install 2.2.3
rbenv global 2.2.3
ruby -v

Cài Rails

Rất đơn giản:

gem install rails -v 4.2.4

Để sử dụng được lệnh rails, chúng ta cần cho rbenv thấy nó:

rbenv rehash

Và giờ chúng ta có thể xác nhận được Rails đã được cài:

rails -v
# Rails 4.2.4

Tạo ứng dụng Rails của bạn:

rails new myapp

#### If you want to use MySQL
rails new myapp -d mysql

#### If you want to use Postgres
# Note you will need to change config/database.yml's username to be
# the same as your OSX user account. (for example, mine is 'chris')
rails new myapp -d postgresql

# Move into the application directory
cd myapp

# If you setup MySQL or Postgres with a username/password, modify the
# config/database.yml file to contain the username/password that you specified

# Create the database
rake db:create

rails server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment