consolidating first two exercises into hodgepodge
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
class HelloController < ApplicationController
|
||||
def world
|
||||
end
|
||||
|
||||
end
|
25
cookbook/015/hodgepodge/app/controllers/novel_controller.rb
Normal file
25
cookbook/015/hodgepodge/app/controllers/novel_controller.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
$one = 1
|
||||
|
||||
class NovelController < ApplicationController
|
||||
$two = 2
|
||||
|
||||
def index
|
||||
@title = 'Shattered View: a Novel on Rails'
|
||||
one_plus_one = 1 + 1
|
||||
increment_counter one_plus_one
|
||||
end
|
||||
|
||||
def helper_method
|
||||
@help_message = "I see you've come to me for help."
|
||||
end
|
||||
|
||||
def increment_counter(by)
|
||||
@counter ||= 0
|
||||
@counter += by
|
||||
end
|
||||
|
||||
def sequel
|
||||
$three = 3
|
||||
end
|
||||
|
||||
end
|
@@ -0,0 +1,7 @@
|
||||
class StatusController < ApplicationController
|
||||
def index
|
||||
time = Time.now
|
||||
@time = time
|
||||
@ps = `ps aux`
|
||||
end
|
||||
end
|
11
cookbook/015/hodgepodge/app/views/hello/world.html.erb
Normal file
11
cookbook/015/hodgepodge/app/views/hello/world.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<h1>Several increasingly silly ways of displaying “Hello world!”:</h1>
|
||||
|
||||
<p><%= "Hello world!" %></p>
|
||||
<p><%= "Hello" + " world!" %></p>
|
||||
<p><%= w = "world"
|
||||
"Hello #{w}!" %></p>
|
||||
<p><%= 'H' + ?e.chr + ('l' * 2) %><%= ('o word!').gsub('d', 'ld')%></p>
|
||||
|
||||
<% hello = "Hello" %>
|
||||
<% world = "world!" %>
|
||||
<%= hello %> <%= world %>
|
@@ -2,13 +2,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Hodgepodge</title>
|
||||
<%= stylesheet_link_tag :all %>
|
||||
<%= javascript_include_tag :defaults %>
|
||||
<%= csrf_meta_tag %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
|
6
cookbook/015/hodgepodge/app/views/novel/index.html.erb
Normal file
6
cookbook/015/hodgepodge/app/views/novel/index.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1><%= @title %></h1>
|
||||
|
||||
<p>I looked up, but saw only the number <%= @counter %></p>
|
||||
|
||||
<p>“What are you doing here?” I asked sharply. “Was it
|
||||
<%= @counter.succ %> who sent you?”</p>
|
2
cookbook/015/hodgepodge/app/views/novel/sequel.html.erb
Normal file
2
cookbook/015/hodgepodge/app/views/novel/sequel.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<p>Here they come, the counting numbers,
|
||||
<%= $one %>, <%= $two %>, <%= $three %>.</p>
|
2
cookbook/015/hodgepodge/app/views/status/index.html.erb
Normal file
2
cookbook/015/hodgepodge/app/views/status/index.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>Processes running at <%= @time %></h1>
|
||||
<pre><%= @ps %></pre>
|
Reference in New Issue
Block a user