Skip to content

Commit 0a387f2

Browse files
authored
Fix Rack slides (#242)
* Fix Rack slides * Fix typo
1 parent 279e73a commit 0a387f2

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

slides/rack.markdown

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,24 +216,25 @@ config.ru <!-- .element: class="filename" -->
216216

217217
```ruby
218218
require './middlewares/racker'
219-
run Racker.new
219+
220+
run Middlewares::Racker.new
220221
```
221222

222-
lib/racker.rb <!-- .element: class="filename" -->
223+
middlewares/racker.rb <!-- .element: class="filename" -->
223224

224225
```ruby
225226
require 'erb'
226227

227228
module Middlewares
228229
class Racker
229230
def call(env)
230-
Rack::Response.new(render('index.html.erb'))
231+
Rack::Response.new(render('index.html.erb')).finish
231232
end
232233

233234
private
234235

235236
def render(template)
236-
path = File.expand_path("../views/#{template}", __FILE__)
237+
path = File.expand_path("../lib/views/#{template}", __FILE__)
237238
ERB.new(File.read(path)).result(binding)
238239
end
239240
end
@@ -345,6 +346,7 @@ config.ru <!-- .element: class="filename" -->
345346

346347
```ruby
347348
require './middlewares/racker'
349+
348350
run Middlewares::Racker
349351
```
350352

@@ -378,7 +380,7 @@ module Middlewares
378380
end
379381

380382
def render(template)
381-
path = File.expand_path("../views/#{template}", __FILE__)
383+
path = File.expand_path("../lib/views/#{template}", __FILE__)
382384
ERB.new(File.read(path)).result(binding)
383385
end
384386

@@ -455,7 +457,7 @@ lib/views/index.html.erb <!-- .element: class="filename" -->
455457
<body>
456458
<div id="container">
457459
<h1>You said '<%= word %>'</h1>
458-
<p>Say somthing new</p>
460+
<p>Say something new</p>
459461
<form method="post" action="/update_word">
460462
<input name="word" type="text">
461463
<input type="submit" value="Say!">
@@ -523,7 +525,7 @@ Url to Rack::Static - https://github.com/rack/rack/blob/master/lib/rack/static.r
523525

524526
## Rack::Reloader
525527

526-
When you change some code in your application or in `config.ru` you need to 'rackup' your application one more time.
528+
When you change some code in your application (except `config.ru`) you need to 'rackup' your application one more time.
527529
The reason is that `Rack` is not able to reload the code of application.
528530

529531
For such reason, it's recommended to use `Rack::Reloader` middleware

0 commit comments

Comments
 (0)