ruby cloud9部署到heroku

Cloud9网址:https://c9.io/

使用github账号登陆,如果没有,现在github(https://github.com/)上注册一个用户,在进行登陆。

 

  • 创建workspace




  • 使用git从github上克隆并创建项目

    git源地址:http://cgao_rottenpotatoes-rails-intro@repository.trustie.net/cgao/rottenpotatoes-rails-intro.git


    在命令行里输入:git clone http://cgao_rottenpotatoes-rails-intro@repository.trustie.net/cgao/rottenpotatoes-rails-intro.git
    密码是:20150917
    按照提示输入密码即可。

  • 找到gemfile文件,注释掉 ruby '2.2.3',如下图所示,修改之后ctrl+s保存
  • 再找到app->models->movie.rb文件,将:Rating的大写R修改为小写r(不然部署到heroku上将会出错),如下图所示,修改之后ctrl+s保存


  • cd 进入到rottenpotatoes-rails-intro目录,输入:cd rottenpotatoes-rails-intro
  • bundle install
  • 数据库迁移:rake db:migrate
  • rake db:seed
  • rails s -p $PORT -b $IP

  • 现在可以将应用部署到heroku上了
    使用git生成public ssh key,输入:ssh-keygen -t rsa

    登陆heroku,输入:heroku login

    将生成public ssh key添加到heroku上,输入:heroku keys:add
  • heroku create
    heroku应用程序名:desolate-ocean-9606
    heroku部署成功后的访问链接:https://desolate-ocean-9606.herokuapp.com/,在后面需要使用。如下图所示
  • git add .
    (git add .表示将所有修改过的工作文件提交暂存区)
    注意:由于修改了文件,所以需要执行git add .,将改变的一起上传到heroku上
  • git commit -m '2015-10-30 20:34'
    (git commit –m "你的注释"表示提交你的修改)
  • git push heroku master
  • 输入:heroku run rake db:migrate --app desolate-ocean-9606
    注意:desolate-ocean-9606是前面heroku create生成的应用程序名
  • 输入:heroku run rake db:seed --app desolate-ocean-9606
    注意:desolate-ocean-9606是前面heroku create生成的应用程序名
  • ok,最后输入:heroku open

posted on 2015-10-30 20:48  jec  阅读(788)  评论(0编辑  收藏  举报

导航