Ruby on Rails + Mongodb + AngularJS develop environment setup

3/9/2017 posted in  编程 comments

Before start, make sure that:
1. You are using macOS or Ubuntu 14.04(or higher)

  1. basic system tools like git are installed. If you are using macOS, make sure you have Xcode/ Xcode Tool Chain installed.

Installation guide

Install Ruby and Rails

Check this guide on ruby-china(https://ruby-china.org/wiki/install_ruby_guide)

some advice

  1. use rvm or rbenv for better performance.

  2. use ⌘ gem install rails -v 4.1.4 will install the specific version of rails.

Install Mongodb

Follow this guide on mongodb.org (https://docs.mongodb.com/manual/installation/)

If you are using macOS, try use homebrew for all the installation.
brew install mongodb

Install angularjs

We are using bower for front-end js package management, so you should install nodejs and use npm install bower first.

  1. install node and npm. check documents on https://nodejs.org/en/

    Try to use nvm instead of install from the website. Official installer may cause npm not work. (This may be a bug, I have encounter this on macOS and Ubuntu many times). If you installed this official build, and encounter the same problems, JUST USE NVM.
    nvm guide:
    1. use the script to install nvm. (The script is shown on nvm GitHub project).
    2. use nvm install <version> to install a specific version of node. for example: nvm install 6.10.0.
    3. use nvm alias default <version> to make this node version as your default version, so you don't need to choose every time you open a new terminal.
    4. use node -v and npm -v to check whether you have these tools installed.
    5. now you can use npm install ⌘ to install node packages.

  2. install bower using npm npm install -g bower check documents on https://bower.io/#install-bower

SSH key

ssh key is used to communicate with gitlab server, follow these steps:

  1. open your terminal and run ⌘ ssh-keygen -t rsa

  2. just use default options and set no password, and ssh key will be generated.

  3. run ⌘ cat ~/.ssh/id_rsa.pub, copy the ssh key, and add it to your github account.

Run guide

make sure you have git ruby rails mongodb bower installed first.

  1. git clone

  2. cd to project folder and run ⌘ bundle install

  3. run ⌘ bower install

  4. run ⌘ rails s - this is for development, if you wanna run rails in production mode, use rails s -e production.

    -e is used to environments, default is development.

  5. check output.