C9+heroku部署

ruby on rails总结:
C9中开发:
 --若新建workspace,需要安装Rails:gem install rails -v 5.1.6(注意版本号)
 --若直接创建项目,则执行:rails _版本号_ new 项目名(rails _5.1.6_ new hello_app)
    1.进入项目路径:cd 项目名
    2.修改Gemfile,直接可参考hello_app的
    3.下载依赖包:bundle install/bundle install --without production(不安装生产环境),有时候需要bundle update
    4.运行rails server服务器:rails server -p $PORT -b $IP
    5.利用脚手架(scaffold)来生产rails的数据模型:
       rails generate scaffold 数据模型名(User) 变量(name):数据类型(string) 变量email:数据类型(string)
    6.迁移数据库:rails db:migrate    还原数据库:rails db:migrate:reset    执行种子:rails db:seed
    7.使用控制台:rails console        退出:exit
    8.测试  rails test
    9.往某个文件里下载图片  curl -o app/assets/images/rails.png -OL railstutorial-china.org/assets/images/rails.png
    10.如果遇到rails console无法使用,则:rm /home/ubuntu/.irbrc  删除该文件
  
heroku部署:
   1.使用git生成public ssh key,输入:ssh-keygen -t rsa (直接按回车就好)
   2.登陆heroku,输入:heroku login
   3.将生成public ssh key添加到heroku上,输入:heroku keys:add
   4.heroku create
   5.若是第一次提交:git init
   6.git add .(git add .表示将所有修改过的工作文件提交暂存区)
   7.提交:git commit -m '注释'
   8.提交到heroku里:git push heroku master
   9.heroku run rake db:migrate --app (生成的链接名字)desolate-ocean-9606
   10. heroku run rake db:seed --app (生成的链接名字)desolate-ocean-9606
   11.heroku open
 
代码托管(trust):
   1.git add .
   2.git commit -m 注释
   3.git push
   4.输入账号密码 

posted @ 2018-12-17 22:33  蒙古小铁驴  阅读(143)  评论(0编辑  收藏  举报