RoR 搭建web应用

Installing Rails

  1. mac 环境默认装有ruby ,ruby -v 查看版本

  2. 替换gem源

    gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
  3. 安装Rails

    sudo gem install rails
  4. 测试安装是否正确

    ❯ rails -v
    Rails 6.0.2.2

Createing Application

rails new blog

替换Gemfile的 source为 source 'https://gems.ruby-china.com' 然后在bundle install

注:Since Rails 6, Webpacker is the default JavaScript compiler. So you’ll also have to set it up before starting your Rails server.

  1. Install yarn using your OS package manager, or take a look at https://yarnpkg.com/en/docs/install
  2. Set it up rails webpacker:install
  3. Make sure all packages are up to date yarn install --check-files
  4. Start your Rails server rails s

Node.js pros and cons

Node.js pros Node.js cons
It represents the “JavaScript everywhere” paradigm
It’s fast
It’s lightweight
It’s scalable
Easy working with large files
It handles multiple requests simultaneously
It is growing really fast
Good community around it
Low maturity
No multithreading
Can be rather unstable

Ruby on Rails pros and cons

Ruby on Rails pros Ruby on Rails cons
Speed of development
Simple, English-like syntax
Good community around it
Open-source solution with a rich set of gems
Convention Over Configuration
Low performance
Low scalability
Slow runtime speed
Lack of flexibility
Open-source solution with a (too) rich set of gems