Skip to content

Instantly share code, notes, and snippets.

@eltonvs
Last active September 14, 2017 13:16
Show Gist options
  • Save eltonvs/b4537afdea9cca0215ff4a2caef37031 to your computer and use it in GitHub Desktop.
Save eltonvs/b4537afdea9cca0215ff4a2caef37031 to your computer and use it in GitHub Desktop.

Installation

This tutorial assumes that you're using Ubuntu 16.04

Install rvm

For goodness' sake, don't use the apt-get approach to install ruby, use rvm. You just need to follow these steps: https://github.com/rvm/ubuntu_rvm

Install mongodb

To install:

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
$ echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
$ sudo apt update
$ sudo apt install -y mongodb-org

Or in a one-line approach (to just copy/paste on your console...)

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 && echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list && sudo apt update && sudo apt install -y mongodb-org

To start:

$ sudo systemctl start mongodb

Install RuboCop

RuboCop is a Ruby static code analyzer (Software Testing I class...) and it's already configured with our defined guidelines to Ruby development.

So install it and use some extension to your favorite editor (like Sublime Linter RoboCop (needs Sublime Linter extension) or Vim Synstastic - Recommended)

$ gem install rubocop

Install Rails

Some of the most important parts to develop in Ruby on Rails...

$ gem install rails

Starting a Rails project with mongodb

You'll use this only to create personal applications or to study, in case that our main project is already configured, so your work will be just to install dependencies with bundle. But, for learning proposals...

$ rails new project_name --skip-active-record

After that, enter on your project folder and add this line to Gemfile (you can put before groups)

gem 'mongoid', '~> 6.0'

To install and reconfigure project, run (on project folder, of course):

$ bundle
$ rails generate mongoid:config

All done, your Ruby on Rails is already configured to use MongoDB instead SQLite. And you can just run rails server to see it in action.

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