railsbridge / workshop

materials for Ruby on Rails intro workshop

workshop / create_webapp-notes.html
100644 141 lines (109 sloc) 3.041 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<h1>Build and deploy a web application</h1>
 
<ul>
<li>Add topics</li>
<li>Vote on a topic</li>
<li>Register and login</li>
</ul>
 
<p><img src="http://www.ultrasaurus.com/rubyworkshop/app_design/authenticated_home.jpg" width="934" height="436"/></p>
 
<h1>let's build a web app</h1>
 
<p><code>
     rails suggestorama
</code></p>
 
<table>
    <tr>
        <th>File/Folder</th>
        <th>Purpose</th>
    </tr>
    <tr>
        <td><span class="caps">README</span></td>
        <td>This is a brief instruction manual for your application.</td>
 
    </tr>
    <tr>
        <td>Rakefile</td>
        <td>This file contains batch jobs that can be run from the terminal.</td>
    </tr>
    <tr>
        <td>app/</td>
 
        <td>Contains the controllers, models, and views for your application. You will mostly work here.</td>
    </tr>
    <tr>
        <td>config/</td>
        <td>Configure your application&#8217;s runtime rules, routes, database, and more.</td>
    </tr>
 
    <tr>
        <td>db/</td>
        <td>Shows your current database schema, as well as the database migrations. </td>
    </tr>
    <tr>
        <td>doc/</td>
        <td>In-depth documentation for your application.</td>
 
    </tr>
    <tr>
        <td>lib/</td>
        <td>Extended modules for your application (not covered today).</td>
    </tr>
    <tr>
        <td>log/</td>
 
        <td>Application log files.</td>
    </tr>
    <tr>
        <td>public/</td>
        <td>The only folder seen to the world as-is. This is where your images, javascript, stylesheets (<span class="caps">CSS</span>), and other static files go.</td>
    </tr>
 
    <tr>
        <td>script/</td>
        <td>Scripts provided by Rails to do recurring tasks. We'll use some today.</td>
    </tr>
    <tr>
        <td>test/</td>
        <td>Unit tests, fixtures, and other test apparatus.</td>
 
    </tr>
    <tr>
        <td>tmp/</td>
        <td>Temporary files</td>
    </tr>
    <tr>
        <td>vendor/</td>
 
        <td>A place for third-party code. </td>
    </tr>
</table>
 
<h1>run the web app</h1>
 
<pre><code>ruby script/server
 
http://localhost:3000
</code></pre>
 
<h1>make it your own</h1>
 
<ul>
<li>modify public/index.html</li>
<li>run it again</li>
</ul>
 
<h1>Awesome! Let's ship it!</h1>
 
<ul>
<li>we'll create a local git repository</li>
<li>then deploy to heroku</li>
</ul>
 
<p>. </p>
 
<pre><code>git init
git add .
git commit -m 'basic web application'
</code></pre>
 
<p>.</p>
 
<pre><code>heroku create
git push heroku master
</code></pre>
 
<h1>push code to github</h1>
 
<ul>
<li>create a repository</li>
<li>follow the instructions for existing repository</li>
</ul>
 
<p><code>
    git config --global user.name "Your Name"
    git config --global user.email you@whatever.com
    git remote add origin git@github.com:yourgithubname/project.git
    git push origin master
</code></p>
 
<h1>switch computers</h1>
 
<p>.</p>
 
<pre><code>git clone git://github.com/yourgitname/project.git
git pull
</code></pre>
 
<p>TODO: add Heroku collaborator? how to set up?</p>