markdown 部署到Heroku

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 部署到Heroku相关的知识,希望对你有一定的参考价值。

### Deploying to Heroku
* Create your rails app
    * Run your completed app on the browser using `rails s` to ensure the site is working
* Add `git init` to your repo
* Run `gem install heroku`
    * run `heroku` for manual, `heroku help ___` for more information
* To create your sub-domain: `heroku create sub-domain-name`
    * If you don't provide a name, heroku will generate one for you
* **Make sure you have an account with heroku before you push your repo to it!** 
* After creating account, you can push to heroku: `git push heroku master`
    * Make sure you specify which branch to push to heroku!
* Once heroku is done installing all the gems, it will provide you with the link to access your site.
    * Copy and paste the link in to your broswer or type in the terminal: `heroku open` to launch
    the site.
* At this point, you can run your migrations and seeded data locally for the SQLite DB.

### Connecting to your app
* `heroku git:remote -a app-name`

### Errors with SQLite DB
* After completing the steps above, you will encounter errors preventing your page from loading.
* You can check `heroku logs` to find the error:
    * `ActiveRecord::ConnectionNotEstablished ...` => need to migrate your database!!!!
* Run `heroku rake db:migrate`
* Error: `Please install the postgresql adapter`
    * **HEROKU DOES NOT WORK WITH SQLITE!!!**
    * Edit`Gemfile`:
    
    ```ruby
    group :test do
    ...
    end
    
    #ADD this new code
    group :production do
      gem 'pg'
    end
    ```
    
* Run `bundle`
* Update heroku with the new file changes, `git add . git commit -m " "`
* Run `git push heroku master` or the name of your branch that you are working on 
* You'll need to run the migrations again, now that you have the appropriate database
    * `heroku rake db:migrate`
    * Tables should successfully be created at this point!
* ERROR: If you encounter `ActionView::Template::Error (application.css isn't precompiled):`
    * run `bundle exec rake assets:precompile`
* Add and commit to `git push heroku master`
* Or pushing from another branch: `git push heroku yourbranch:master`

### Transferring Date from SQLite DB to PostgreSQL DB
* Reload page, should not encounter any other errors.
* You're site contains an empty DB, to transfer data over:
    * Make sure you have `taps` gem installed! `gem install taps`
    * Run `heroku db:push`
    * The log should indicate the number of tables and records uploaded

以上是关于markdown 部署到Heroku的主要内容,如果未能解决你的问题,请参考以下文章

如何将nodejs和vuejs部署到heroku

将nodejs部署到heroku

将应用程序部署到 Heroku 后无法推送到 Github

MERN 应用程序在部署到 Heroku 时无法运行“heroku-postbuild”脚本

无法将python代码部署到heroku

如何更新使用 GitHub“部署到 Heroku”按钮创建的 Heroku 应用程序?