-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
501 lines (487 loc) · 14.8 KB
/
index.html
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Ruby on Rails</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/league.css">
<link rel="stylesheet" href="css/custom.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/languages/bash.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/languages/ruby.min.js"></script>
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match(/print-pdf/gi) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName('head')[0].appendChild(link);
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h2>Welcome</h2>
<img src="images/multunus.png" class="logo" />
<p><a href="http://www.bit.ly/firstslk">http://bit.ly/firstslk</a></p>
</section>
<section>
<p><a href="https://www.ruby-lang.org/en//">Ruby</a></p>
<img class="logo" src="images/ruby.png" />
</section>
<section>
<p><a href="https://www.ruby-lang.org/en/documentation/installation/#apt">Install Ruby</a></p>
<pre>
<code class='bash'>
$ sudo apt-get update
$ sudo apt-get install curl
$ curl -L https://get.rvm.io | bash -s stable
$ rvm install 2.2.2
</code>
</pre>
</section>
<section>
<p><a href="https://http://bundler.io/#getting-started">Install Bundler</a></p>
<pre>
<code class='bash'>
$ gem install bundler
</code>
</pre>
</section>
<section>
<h3>Hello world!</h3>
<pre class='bash'>
$ irb
irb(main):010:0> def hi
irb(main):011:1> puts "Hello World!"
irb(main):012:1> end
:hi
</pre>
</section>
<section>
<h3>Function</h3>
<pre>
<code class='bash'>
> def hi(name)
> puts "Hello #{name}!"
> end
:hi
> hi("Matz")
Hello Matz!
nil
</code>
</pre>
</section>
<section>
<h3>Class</h3>
<pre>
<code class='ruby'>
class Greeter
def initialize(name = "World")
@name = name
end
def say_hi
puts "Hi #{@name}!"
end
def say_bye
puts "Bye #{@name}, come back soon."
end
end
</code>
</pre>
</section>
<section>
<h3>Object</h3>
<pre>
<code class='ruby'>
greeter = Greeter.new("Pat")
greeter.say_hi
Hi Pat!
nil
greeter.say_bye
Bye Pat, come back soon.
nil
</code>
</pre>
</section>
<section>
<p><a href="http://rubyonrails.org/">Ruby on Rails</a></p>
<img class="logo" src="images/ror.png" />
</section>
<section>
<p>Install Rails</a>
</p>
<pre><code class='bash'>$ gem install rails -v 5.0.1</code></pre>
</section>
<section>
<h3>Your first App</h3>
<pre>
<code class='bash'>
$ rails _5.0.1_ new hello_world
$ cd hello_world
$ sudo apt-get install nodejs #if there is an error
$ bundle install
$ rails server
</code>
</pre>
</section>
<section>
<h3>Your first App</h3>
<div class='file-path'><span>app/controllers/application_controller.rb</span></div>
<pre>
<code class='ruby'>
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def hello
render html: "hello, world!"
end
end
</code>
</pre>
</section>
<section>
<h3>Routing</h3>
<div class='file-path'><span>config/routes.rb</span></div>
<pre>
<code class='ruby'>
Rails.application.routes.draw do
root 'application#hello'
end
</code>
</pre>
</section>
<!-- Version Control -->
<section>
<h3>Version Control</h3>
<pre>
<code class='bash'>
$ sudo apt-get install git-all
$ git config --global user.name "Your Name"
$ git config --global user.email [email protected]
</code>
</pre>
</section>
<!-- Version control -->
<section>
<p>Let's make some Tweeter©</p>
<pre>
<code class='bash'>
$ cd
$ rails _5.0.1_ new tweeter_app
$ cd tweeter_app
</code>
</pre>
<p>Or</p>
<pre>
<code class='bash'>
$ git clone https://github.com/multunus/rails-workshop
</code>
</pre>
<a href="http://bit.ly/rorwsp">bit.ly/rorwsp</a>
</section>
<section>
<h3>Model-View-Controller</h3>
</section>
<section>
<img class="image" src="images/mvc.png">
</section>
<section>
<p>Users</p>
<table>
<tr>
<td>id</td>
<td>a unique identifier</td>
</tr>
<tr>
<td>name</td>
<td>name of the user</td>
</tr>
<tr>
<td>email</td>
<td>email id of the user</td>
</tr>
</table>
</section>
<section>
<p>Microposts</p>
<table>
<tr>
<td>id</td>
<td>a unique identifier</td>
</tr>
<tr>
<td>content</td>
<td>content of the post</td>
</tr>
<tr>
<td>user_id</td>
<td>the unique identifier of the user</td>
</tr>
</table>
</section>
<section>
<p>Day 1: Let there be light... or User</p>
<pre>
<code class='bash'>
$ rails generate scaffold User name:string email:string
$ rake db:migrate
</code>
</pre>
</section>
<section>
<p>Routes and Actions for User</p>
<table>
<tr>
<td>GET</td>
<td>/users</td>
<td>index</td>
<td>page to list all users</td>
</tr>
<tr>
<td>GET</td>
<td>/users/1</td>
<td>show</td>
<td>page to show user with id 1</td>
</tr>
<tr>
<td>GET</td>
<td>/users/new</td>
<td>new</td>
<td>page to make a new user</td>
</tr>
<tr>
<td>GET</td>
<td>/users/1/edit</td>
<td>edit</td>
<td>page to edit user with id 1</td>
</tr>
</table>
</section>
<section>
<p>More Actions</p>
<table>
<tr>
<td>POST</td>
<td>/users</td>
<td>create</td>
<td>create a new user</td>
</tr>
<tr>
<td>PATCH</td>
<td>/users/1</td>
<td>update</td>
<td>update a user 1</td>
</tr>
<tr>
<td>DELETE</td>
<td>/users/1</td>
<td>destroy</td>
<td>delete user with id 1</td>
</tr>
</table>
</section>
<section>
<p>Magically a route appears!</p>
<div class='file-path'><span>config/routes.rb</span></div>
<pre>
<code class='ruby'>
Rails.application.routes.draw do
resources :users
end
</code>
</pre>
</section>
<section>
<p>Day 2: And the User was without Micropost</p>
<pre>
<code class='bash'>
$ rails generate scaffold Micropost content:text user_id:integer
$ rake db:migrate
</code>
</pre>
</section>
<section>
<p>Routes and Actions for Micropost</p>
<table>
<tr>
<td>GET</td>
<td>/microposts</td>
<td>index</td>
<td>page to list all microposts</td>
</tr>
<tr>
<td>GET</td>
<td>/microposts/1</td>
<td>show</td>
<td>page to show post with id 1</td>
</tr>
<tr>
<td>GET</td>
<td>/microposts/new</td>
<td>new</td>
<td>page to make a new post</td>
</tr>
<tr>
<td>GET</td>
<td>/microposts/1/edit</td>
<td>edit</td>
<td>page to edit post with id 1</td>
</tr>
</table>
</section>
<section>
<p>More Actions</p>
<table>
<tr>
<td>POST</td>
<td>/microposts</td>
<td>create</td>
<td>create a new post</td>
</tr>
<tr>
<td>PATCH</td>
<td>/microposts/1</td>
<td>update</td>
<td>update a post 1</td>
</tr>
<tr>
<td>DELETE</td>
<td>/microposts/1</td>
<td>destroy</td>
<td>delete post with id 1</td>
</tr>
</table>
</section>
<section>
<p>(Not so) Magically a route appears!</p>
<div class='file-path'><span>config/routes.rb</span></div>
<pre>
<code class='ruby'>
Rails.application.routes.draw do
resources :microposts #new resource
resources :users
end
</code>
</pre>
</section>
<section>
<p>Where the @#$%! is my <b>micro</b> post?</p>
<div class='file-path'><span>app/models/micropost.rb</span></div>
<pre>
<code class='ruby'>
class Micropost < ApplicationRecord
validates :content, length: { maximum: 140 }
end
</code>
</pre>
</section>
<section>
<p>But, User <em>has many</em> Micropost!</p>
<div class='file-path'><span>app/models/user.rb</span></div>
<pre>
<code class='ruby'>
class User < ApplicationRecord
has_many :microposts
end
</code>
</pre>
</section>
<section>
<p>And a Micropost <em>belongs to</em> a User</p>
<div class='file-path'><span>app/models/micropost.rb</span></div>
<pre>
<code class='ruby'>
class Micropost < ApplicationRecord
belongs_to :user #microposts belongs to user
validates :user, presence: true # micropost exists only if user exist
validates :content, length: { maximum: 140 }
end
</code>
</pre>
</section>
<section>
<p>Association</p>
<img src="images/association.png" class="small image">
</section>
<section>
<p>Why u no type content?</p>
<div class='file-path'><span>app/models/micropost.rb</span></div>
<pre>
<code class='ruby'>
class Micropost < ApplicationRecord
belongs_to :user
validates :user, presence: true
validates :content, length: { maximum: 140 }, presence: true # micropost should have some content
end
</code>
</pre>
</section>
<section>
<p>Static pages? Rails can do that for you</p>
<pre>
<code class='bash'>
$ rails generate controller StaticPages home help
</code>
</pre>
</section>
<section>
<p>Static pages</p>
<div class='file-path'><span>config/routes.rb</span></div>
<pre>
<code class='ruby'>
Rails.application.routes.draw do
get 'static_pages/home'
get 'static_pages/help'
root 'application#hello'
end
</code>
</pre>
</section>
<section>
<div class='file-path'><span>app/views/static_pages/home.html.er</span></div>
<pre>
<code class='html'>
<h1>Welcome to Tweeter</h1>
<p>
This is the home page for my Twitter application.
</p>
<%= link_to 'New User', new_user_path %>
<%= link_to 'New Micropost', new_micropost_path %>
</code>
</pre>
</section>
<section>
<h2>Arigatho... Sayonara...</h2>
<img src="images/multunus.png" class="logo" />
<p><a href="http://www.bit.ly/firstghb">http://bit.ly/firstghb</a></p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
history: true,
// More info https://github.com/hakimel/reveal.js#dependencies
dependencies: [{
src: 'plugin/markdown/marked.js'
}, {
src: 'plugin/markdown/markdown.js'
}, {
src: 'plugin/notes/notes.js',
async: true
}, {
src: 'plugin/highlight/highlight.js',
async: true,
callback: function() {
hljs.initHighlightingOnLoad();
}
}]
});
</script>
</body>
</html>