You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Finally, our basic blog has been built and we should deploy our application so
the world can check it out! The easiest way to do this quickly and for free is
to use a service such as Heroku. Let's deploy our application to Heroku right
now.
Now, to deploy to Heroku, the application needs to be set up as a Git
repository:
$ cd sample-blog-updated
$ git init
$ git add .
$ git commit -m "initial commit for app"
This initializes the Git repository, adds all the contents and commit them to
the repo.
Currently Padrino defaults to SQLite but Heroku only supports PostgreSQL, so we'll need to add pg gem as a dependency for production as well add sqlite3
for development.
$ heroku login
Enter your Heroku credentials.
Email: <your-email>
Password (typing will be hidden):
Logged in as <your-email>
$ heroku create
Creating app... done, ⬢ secret-taiga-32690
https://secret-taiga-32690.herokuapp.com/ | https://git.heroku.com/secret-taiga-32690.git
$ git push heroku master
That's it, your app is now running on Heroku! To see if we have a database addon connected
to out heroku app, run heroku addons:
$ heroku addons
Add-on Plan Price
─────────────────────────────────────────── ───────── ─────
heroku-postgresql (postgresql-taiga-32690) hobby-dev free
└─ as DATABASE
and configure the config/database.rb for production:
# config/database.rbSequel::Model.plugin(:schema)Sequel::Model.raise_on_save_failure=false# Do not throw exceptions on failureSequel::Model.db=casePadrino.envwhen:developmentthenSequel.connect("sqlite://db/blog_tutorial_development.db",:loggers=>[logger])when:productionthenSequel.connect("<your-url>",:loggers=>[logger])when:testthenSequel.connect("sqlite://db/blog_tutorial_test.db",:loggers=>[logger])end
You can get the value of <your-url> via heroku config.
Run heroku open to open your site in your default web browser.
Now run our migrations/seeds:
$ heroku run rake sq:migrate
$ heroku run rake sq:seed
You'll see something like:
$ heroku run rake ar:migrate
Running rake ar:migrate on calm-tor-92217.... up, run.7316
== 1 CreateAccounts: migrating ================================================
-- create_table(:accounts)
-> 0.0162s
== 1 CreateAccounts: migrated (0.0164s) =======================================
== 2 CreatePosts: migrating ===================================================
-- create_table(:posts)
-> 0.0078s
== 2 CreatePosts: migrated (0.0080s) ==========================================
== 3 AddAccountToPost: migrating ==============================================
-- change_table(:posts)
-> 0.0048s
== 3 AddAccountToPost: migrated (0.0254s) =====================================
$ heroku run rake seed
Running rake seed on calm-tor-92217.... up, run.9169
Which email do you want use for logging into admin?
Tell me the password to use:
=================================================================
Account has been successfully created, now you can login with:
=================================================================
email: [email protected]
password: *****
=================================================================
Deploying your application on heroku
Finally, our basic blog has been built and we should deploy our application so
the world can check it out! The easiest way to do this quickly and for free is
to use a service such as Heroku. Let's deploy our application to Heroku right
now.
The best way to get started using Heroku is by following the
Heroku Quickstart Guide. As explained in the guide, be sure to have Git installed and
setup a Heroku account as
well as
install the Heroku command-line tool before continuing this tutorial.
Now, to deploy to Heroku, the application needs to be set up as a Git
repository:
This initializes the Git repository, adds all the contents and commit them to
the repo.
Currently Padrino defaults to SQLite but Heroku only supports
PostgreSQL, so we'll need to add
pg
gem as a dependency for production as well addsqlite3
for development.
Now you can bundle :
and then commit these changes to your git repository:
$ git add --all $ git commit -m "added pg dependency"
Next, the application must be set up on Heroku.
That's it, your app is now running on Heroku! To see if we have a database addon connected
to out heroku app, run
heroku addons
:and configure the
config/database.rb
for production:You can get the value of
<your-url>
viaheroku config
.Run
heroku open
to open your site in your default web browser.Now run our
migrations/seeds
:You'll see something like:
Now let's open our newly deployed app:
and surf. You can see posts and the
admin screen.
Enjoy!
The text was updated successfully, but these errors were encountered: