Skip to content

Commit ab0247f

Browse files
committed
final creds and deploy
1 parent b16537c commit ab0247f

File tree

4 files changed

+149
-1
lines changed

4 files changed

+149
-1
lines changed

commit_changes_to_the_git_repo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ Now you should see something like `nothing to commit`, working directory clean w
5656
By continually checking your code changes into git, you're maintaining a record of your changes. This way, if anything ever breaks, or you make a change you don't like, you can use git as an all-powerful "undo" technique. But that only works when you remember to __commit early and often__!
5757

5858
## Next Step:
59-
Go on to [Creating A Migration](creating_a_migration.md)
59+
Go on to [Credits and Next Steps](credits_and_next_steps.md)

credits_and_next_steps.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Credits And Next Steps
2+
3+
Guess what? ***You're done!!!*** Congratulations, you just "finished" your first rails app!
4+
5+
(They're never *really* ever finished... have fun tweaking it!)
6+
7+
You get another sticker! :)
8+
9+
## Extra Credit
10+
If you got all the way through Suggestotron with some time to spare, here's some extra stuff you can try:
11+
12+
13+
* You've been working on the cloud the entire time, but now you can [Deploy your application to Heroku](deploy_to_heroku.md)
14+
* Share your code! Create a [GitHub](https://github.com/) account, add a repository there, and push your git repository to a new `remote` / github.
15+
* Add a downvote button that does the opposite of what the upvote button does
16+
* Create upvote and downvote methods in the Topic model and use those in the topics controller instead directly modifying the topics votes
17+
* Sort topics by their number of votes
18+
* Add an 'about' page, linked from the bottom of the Suggestotron topics list. Link back to the Topics list from the About page so users don't get stranded.
19+
* If your class has a __lot__ of time left over:
20+
* Users should be allowed to vote only once: give votes a user_id and allow a user to have voted on each topic only once. But wait, what is a 'user' in our system? Get a volunteer to introduce everyone to [Devise](https://github.com/plataformatec/devise), a simple way to add authentication to a Rails application.
21+
* Users should be able to give a post a 'negative' vote instead of a positive one. How might you represent that in this system?
22+
23+
## Authors
24+
* The [RailsBridge community](https://github.com/railsbridge/docs/graphs/contributors)
25+
* ...and maybe you? Pull requests welcome on [GitHub](https://github.com/railsbridge/docs)
26+
27+
## What next?
28+
* Probably time for the closing presentation.
29+
* After that, start a project, tutorial, and come back again!
30+
* All our favorite resources can be found on the RailsBridge site: [http://railsbridge.org/learn/resources](http://railsbridge.org/learn/resources)

deploy_to_heroku.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Deploying To Heroku
2+
3+
If you have already deployed your app to Heroku, go on to [Deploying to Heroku again].
4+
5+
## Step 1: Create a Heroku application
6+
Type this in the bash tab (aka terminal):
7+
```bash
8+
heroku create
9+
```
10+
`heroku create` registers a new application on Heroku's system. You should see some output including your new app's URL.
11+
12+
## Step 2: Edit the Gemfile
13+
14+
---
15+
16+
Each application has its own `Gemfile`. Be sure you're opening the one inside your app's folder.
17+
18+
---
19+
20+
Heroku will run our application slightly differently than our development computer does, which requires us to make a small change to our `Gemfile`.
21+
22+
Open the file called `Gemfile` in Sublime Text, or your preferred editor, and find the line containing:
23+
24+
```ruby
25+
gem 'sqlite3'
26+
```
27+
28+
__Remove that line__ and replace it with:
29+
30+
```ruby
31+
group :development, :test do
32+
gem 'sqlite3'
33+
end
34+
35+
group :production do
36+
gem 'pg'
37+
gem 'rails_12factor'
38+
end
39+
```
40+
41+
## Step 3: Apply the Gemfile changes
42+
Type this in the terminal:
43+
44+
```bash
45+
bundle install --without production
46+
```
47+
48+
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.
49+
50+
## Step 4: Commit the Gemfile changes
51+
There are now changes to `Gemfile` and `Gemfile.lock` that need to be committed before we can push to Heroku.
52+
53+
Type this in the terminal:
54+
55+
```bash
56+
git add Gemfile
57+
git add Gemfile.lock
58+
git commit -m "Changed Gemfile for Heroku"
59+
```
60+
61+
## Step 5: Commit any (other) pending changes to git
62+
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.
63+
64+
Type this in the terminal:
65+
```bash
66+
git status
67+
```
68+
`git status` shows you any pending changes you've created. If it has no output, you're already ready to deploy! Otherwise...
69+
70+
Type this in the terminal:
71+
```bash
72+
git add .
73+
git commit -m "Some helpful message for your future self"
74+
```
75+
Your commit message should reference whatever your outstanding changes are: something like "Added votes to the topics index".
76+
77+
## Step 6: Push changes to Heroku
78+
Type this in the terminal:
79+
```bash
80+
git push heroku master
81+
```
82+
This takes all changes you've committed locally and pushes them to Heroku.
83+
84+
## Step 7: Run database migrations on Heroku
85+
Type this in the terminal:
86+
```bash
87+
heroku run rake db:migrate
88+
```
89+
This tells Heroku to run your migrations on its database, like running rake db:migrate locally.
90+
91+
Heroku's database is separate from the one on your computer (or the one in cloud9), which means it needs to be updated every time you make changes to the structure of your database.
92+
93+
It also means that you'll not see any of the data you entered into the sqlite3 database on your computer.
94+
95+
## Step 8: Visit your application
96+
Type this in the terminal:
97+
```
98+
heroku apps:info
99+
```
100+
101+
This will display a listing of information about your Heroku application. One useful bit of information is your application's `Web URL`. You can copy this URL, open up a new browser tab and paste it into the address bar to see your application running on Heroku.
102+
103+
## Explanation
104+
First, we had to do some work to make Heroku happy with our application. This required updating the `Gemfile` and bundling.
105+
106+
* The `Gemfile` is a list of all the Ruby libraries your application needs. What we've declared here is that we want to use the `sqlite3` library while we're developing on our computer (the development group) but when deploying to Heroku (the production group) we want to use the pg library, which is made for the type of database that Heroku uses.
107+
108+
* Bundler is how Ruby projects keep track of the gems that they use. We told Bundler what we wanted to use in the `Gemfile`, now we need to make sure those gems are installed. Since we don't have the type of database Heroku does, we skip the production gems. Don't worry though! Bundler still logs them so Heroku will install them when they get your code.
109+
110+
You should be able to deploy your application any time it's in a good, working state. Your typical workflow will look like:
111+
112+
1. Add or change some code
113+
1. Test your changes locally (or on cloud9)
114+
1. Commit your changes (git commit)
115+
1. Deploy changes to Heroku (optional)
116+
1. (repeat)
117+
118+
Any time your changes are committed, you should feel free to `git push heroku master` and boom! Your changes are live!

images/workflow.png

56.7 KB
Loading

0 commit comments

Comments
 (0)