Skip to content

Commit c00ab11

Browse files
committed
Move heroku deploy bits to partials
1 parent 7fbf965 commit c00ab11

File tree

4 files changed

+107
-103
lines changed

4 files changed

+107
-103
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
step "Create a Heroku application" do
2+
console "heroku create"
3+
message "`heroku create` registers a new application on Heroku's system. You should see some output including your new app's URL."
4+
end
5+
6+
step "Edit the Gemfile" do
7+
important "Each application has its own `Gemfile`. Be sure you're opening the one inside your app's folder."
8+
9+
message "Heroku will run our application slightly differently than our development computer does, which requires us to make a small change to our `Gemfile`."
10+
11+
message "Open the file called `Gemfile` in Sublime Text, or your preferred editor, and find the line containing:"
12+
13+
source_code :ruby, <<-RUBY
14+
gem 'sqlite3'
15+
RUBY
16+
17+
message "**Remove that line** and replace it with:"
18+
19+
source_code :ruby, <<-RUBY
20+
group :development, :test do
21+
gem 'sqlite3'
22+
end
23+
24+
group :production do
25+
gem 'pg'
26+
gem 'rails_12factor'
27+
end
28+
RUBY
29+
end
30+
31+
step "Apply the Gemfile changes" do
32+
console "bundle install --without production"
33+
message "Every time the `Gemfile` changes, you need to run ``bundle install`` for the changes to be processed. The processed version of the changes is stored in another file called ``Gemfile.lock``."
34+
end
35+
36+
step "Commit the Gemfile changes" do
37+
message "There are now changes to `Gemfile` and `Gemfile.lock` that need to be committed before we can push to Heroku."
38+
console <<-SHELL
39+
git add .
40+
git commit -m "Changed Gemfile for Heroku"
41+
SHELL
42+
tip "There is a period after the word add in the first line."
43+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
step "Commit any pending changes to git" do
2+
message "Heroku will only receive the files we've committed into our local git repository. So we need to make sure all changed files have been committed."
3+
console "git status"
4+
message "`git status` shows you any pending changes you've created. If it has no output, you're already ready to deploy! Otherwise..."
5+
6+
console <<-SHELL
7+
git add .
8+
git commit -m "Some helpful message for your future self"
9+
SHELL
10+
message "Your commit message should reference whatever your outstanding
11+
changes are: something like \"Added votes to the topics index\"."
12+
end
13+
14+
step "Push changes to Heroku" do
15+
console "git push heroku master"
16+
message "This takes all changes you've committed locally and pushes them to Heroku."
17+
end
18+
19+
step "Run database migrations on Heroku" do
20+
console "heroku run rake db:migrate"
21+
message "This tells Heroku to run your migrations on its database, like
22+
running `rake db:migrate` locally."
23+
message "Heroku's database is separate from the one on your computer, which
24+
means it needs to be updated every time you make changes to the structure of
25+
your database."
26+
message "It also means that you'll not see any of the data you entered into
27+
the `sqlite3` database on your computer."
28+
end
29+
30+
step "Visit your application" do
31+
console "heroku open"
32+
message "This opens the new application in your browser."
33+
end
34+
35+
explanation do
36+
message <<-MARKDOWN
37+
First, we had to do some work to make Heroku happy with our application. This
38+
required updating the `Gemfile` and bundling.
39+
40+
* The `Gemfile` is a list of all the Ruby libraries your application needs.
41+
What we've declared here is that we want to use the `sqlite3` library
42+
while we're developing on our computer (the development group) but when
43+
deploying to Heroku (the production group) we want to use the `pg` library,
44+
which is made for the type of database that Heroku uses.
45+
46+
* Bundler is how Ruby projects keep track of the gems that they use. We told
47+
Bundler what we wanted to use in the `Gemfile`, now we need to make sure those
48+
gems are installed. Since we don't have the type of database Heroku does, we
49+
skip the production gems. Don't worry though! Bundler still logs them so
50+
Heroku will install them when they get your code.
51+
MARKDOWN
52+
53+
message "You should be able to deploy your application any time it's in a good, working state. Your typical workflow will look like:"
54+
img src: "img/workflow.png", alt: "Diagram showing git workflow of making changes, committing them, and pushing to Heroku.", style: "border: none"
55+
ol do
56+
li { message "Add or change some code" }
57+
li { message "Commit your changes (`git commit`)" }
58+
li { message "(repeat)" }
59+
end
60+
message "Any time your changes are committed, you should feel free to `git push heroku master` and boom! Your changes are live!"
61+
end

sites/en/intro-to-rails/deploying_to_heroku.step

+2-42
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,6 @@ h2 do
44
span "."
55
end
66

7-
step "Create a Heroku application" do
8-
console "heroku create"
9-
message "`heroku create` registers a new application on Heroku's system. You should see some output including your new app's URL."
10-
end
11-
12-
step "Edit the Gemfile" do
13-
important "Each application has its own `Gemfile`. Be sure you're opening the one inside your app's folder."
14-
15-
message "Heroku will run our application slightly differently than our development computer does, which requires us to make a small change to our `Gemfile`."
16-
17-
message "Open the file called `Gemfile` in Sublime Text, or your preferred editor, and find the line containing:"
18-
19-
source_code :ruby, <<-RUBY
20-
gem 'sqlite3'
21-
RUBY
22-
23-
message "**Remove that line** and replace it with:"
24-
25-
source_code :ruby, <<-RUBY
26-
group :development, :test do
27-
gem 'sqlite3'
28-
end
29-
30-
group :production do
31-
gem 'pg'
32-
gem 'rails_12factor'
33-
end
34-
RUBY
35-
end
7+
insert '_deploying_to_heroku'
368

37-
step "Apply the Gemfile changes" do
38-
console "bundle install --without production"
39-
message "Every time the `Gemfile` changes, you need to run ``bundle install`` for the changes to be processed. The processed version of the changes is stored in another file called ``Gemfile.lock``."
40-
end
41-
42-
step "Commit the Gemfile changes" do
43-
message "There are now changes to `Gemfile` and `Gemfile.lock` that need to be committed before we can push to Heroku."
44-
console <<-SHELL
45-
git add .
46-
git commit -m "Changed Gemfile for Heroku"
47-
SHELL
48-
tip "There is a period after the word add in the first line."
49-
end
9+
insert '_deploying_to_heroku_again'

sites/en/intro-to-rails/deploying_to_heroku_again.step

+1-61
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,4 @@ h2 do
44
span "."
55
end
66

7-
step "Commit any pending changes to git" do
8-
message "Heroku will only receive the files we've committed into our local git repository. So we need to make sure all changed files have been committed."
9-
console "git status"
10-
message "`git status` shows you any pending changes you've created. If it has no output, you're already ready to deploy! Otherwise..."
11-
12-
console <<-SHELL
13-
git add .
14-
git commit -m "Some helpful message for your future self"
15-
SHELL
16-
message "Your commit message should reference whatever your outstanding
17-
changes are: something like \"Added votes to the topics index\"."
18-
end
19-
20-
step "Push changes to Heroku" do
21-
console "git push heroku master"
22-
message "This takes all changes you've committed locally and pushes them to Heroku."
23-
end
24-
25-
step "Run database migrations on Heroku" do
26-
console "heroku run rake db:migrate"
27-
message "This tells Heroku to run your migrations on its database, like
28-
running `rake db:migrate` locally."
29-
message "Heroku's database is separate from the one on your computer, which
30-
means it needs to be updated every time you make changes to the structure of
31-
your database."
32-
message "It also means that you'll not see any of the data you entered into
33-
the `sqlite3` database on your computer."
34-
end
35-
36-
step "Visit your application" do
37-
console "heroku open"
38-
message "This opens the new application in your browser."
39-
end
40-
41-
explanation do
42-
message <<-MARKDOWN
43-
First, we had to do some work to make Heroku happy with our application. This
44-
required updating the `Gemfile` and bundling.
45-
46-
* The `Gemfile` is a list of all the Ruby libraries your application needs.
47-
What we've declared here is that we want to use the `sqlite3` library
48-
while we're developing on our computer (the development group) but when
49-
deploying to Heroku (the production group) we want to use the `pg` library,
50-
which is made for the type of database that Heroku uses.
51-
52-
* Bundler is how Ruby projects keep track of the gems that they use. We told
53-
Bundler what we wanted to use in the `Gemfile`, now we need to make sure those
54-
gems are installed. Since we don't have the type of database Heroku does, we
55-
skip the production gems. Don't worry though! Bundler still logs them so
56-
Heroku will install them when they get your code.
57-
MARKDOWN
58-
59-
message "You should be able to deploy your application any time it's in a good, working state. Your typical workflow will look like:"
60-
img src: "img/workflow.png", alt: "Diagram showing git workflow of making changes, committing them, and pushing to Heroku.", style: "border: none"
61-
ol do
62-
li { message "Add or change some code" }
63-
li { message "Commit your changes (`git commit`)" }
64-
li { message "(repeat)" }
65-
end
66-
message "Any time your changes are committed, you should feel free to `git push heroku master` and boom! Your changes are live!"
67-
end
7+
insert '_deploying_to_heroku_again'

0 commit comments

Comments
 (0)