ubuntu-14.04.5-desktop-amd64

ruby 2.2.0

rails 4.1.4

提示:复制粘贴命令,执行报错就手动输入命令

1. 下载源设置成mirrors.aliyun.com/ubuntu   记得reload

2. install rvm

    ubuntu有自己的安装方式(curl方式会报pgp相关错误)
    ubuntu install rvm 安装方式https://github.com/rvm/ubuntu_rvm

    rvm安装完时的提示:

     * First you need to add all users that will be using rvm to 'rvm' group,
       and logout - login again, anyone using rvm will be operating with `umask

       u=rwx,g=rwx,o=rx`.

    * To start using RVM you need to run `source /etc/profile.d/rvm.sh`
       in all your open shell windows, in rare cases you need to reopen all shell windows.
        提示:terminal rvm: command not found 可以输入/bin/bash -login

    执行下rvm -v察看版本

    rvm 1.27.0 (manual) by Wayne E. Seguin , Michal Papis          [https://rvm.io/]

    rvm安装完成

    rvm说明https://ruby-china.org/wiki/rvm-guide

3.install ruby

    在安装ruby之前执行下rvm list known察看可以安装的ruby版本

    rvm install 2.2.0可以指定某个版本安装

    安装完成后 rvm list察看下版本

    如果有多个版本使用rvm use x.x.x切换版本 (rvm use 2.2.0 --default指定默认版本)

    ruby -v察看ruby版本

    ruby安装完成

    安装方式和管理系统https://www.ruby-lang.org/zh_cn/documentation/installation/

4.安装rails

    gem insatll rails -v 4.1.4 --no-ri --no-rdoc

    显示:

    Successfully installed rails-4.1.4
    24 gems installed


    rails -v 察看下版本

    安装完成

5.启动rails

    rails new app 新建项目

    cd app           进入项目文件夹

 如果显示:

********************************************************************************
* NOTICE                                                                       *
********************************************************************************
* RVM has encountered a new or modified .rvmrc file in the current directory,  *
* this is a shell script and therefore may contain any shell commands.         *
*                                                                              *
* Examine the contents of this file carefully to be sure the contents are      *
* safe before trusting it!                                                     *
* Do you wish to trust '/home/tt/.rvmrc'?                                      *
* Choose v[iew] below to view the contents                                     *
********************************************************************************
y[es], n[o], v[iew], c[ancel]> n  (输入n)

    rails s             启动rails (rails s -p 9000指定端口)

    显示:

   => Booting WEBrick
    => Rails 4.1.4 application starting in development on http://0.0.0.0:3000
    => Run `rails server -h` for more startup options
    => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding             option)
    => Ctrl-C to shutdown server
  [2016-11-29 16:55:10] INFO  WEBrick 1.3.1
  [2016-11-29 16:55:10] INFO  ruby 2.2.0 (2014-12-25) [x86_64-linux]
  [2016-11-29 16:55:10] INFO  WEBrick::HTTPServer#start: pid=10726 port=3000

在浏览器输入http://0.0.0.0:3000 显示Welcome aboard 欢迎页面



 

6.安装 bootstrap
ruby -v 察看版本(ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux])
rails new myapp 新建项目
cd myapp 进入项目文件夹
vi gemfile 编辑文件,增加一行 gem 'bootstrap-sass', '~> 3.3.5'
bundle install 安装

设置
修改app/assets/stylesheets/application.css 为app/assets/stylesheets/application.scss
并添加如下的代码来引用它
@import "bootstrap-sprockets";
@import "bootstrap";
("bootstrap-sprockets"的导入必须写在 "bootstrap" 和"bootstrap/variables"之前
删掉这个文件中所有的//require和//=require_tree标签,都改为@import来引用刚刚下载的zip包里的sass文件。不使用//require是因为这样就无法访问bootstrap的混合类型和变量。)

在app/assets/javascripts/application.js中添加对bootstrap js的引用:
//= require jquery
//= require bootstrap-sprockets
完成设置

rails g scaffold product name price:decimal description:text 创建表    
rake db:migrate 更新数据库
rails s 启动rails
http://0.0.0.0:3000/products 显示默认创建的页面

myapp/views/products/index.html.erb  在页面最后增加以下代码(刷新页面,在下一步安装bootswatch后样式会有改变)



我的第一个 Bootstrap 页面

重置窗口大小,查看响应式效果!

 

Column 1

学的不仅是技术,更是梦想!

再牛逼的梦想,也抵不住你×××似的坚持!