A Brief History of Intangibles in Ad Valorem Taxation.pdf
Rails for zombies slides cc
1. This content is available free on created by
http://RailsForZombies.org
2. Feel free to delete this slide
This means you can use the If you need to charge some
content: money
* You can modify / remix it to run an event which uses this
content
it can not be profitable. i.e. You
should only be charging enough
However: to cover costs.
* You can’t charge money for it
If profit is involved, Envy Labs
* You must keep the attribution deserves a small cut,
probably
don’t you think? Maybe even
consider having Envy Labs teach
it in person perhaps?
Email => Gregg@EnvyLabs.com
This content is available free on created by
http://RailsForZombies.org
3. Recommendations for running
•You’ll need 3-4 for Zombies through the
a Live Rails hours to get
tutorial, with enough time for labs
Tutorial
•Present these slides, then give students
20-30
minutes do do the exercises on
RailsForZombies.org
•Have students go through TryRuby.org
ahead of time,
if they’re not familiar with Ruby
•If you’re not comfortable with presenting
this material
feel free to just play the videos on the
website and Feel free to delete this slid
not use these slides available free on created by
This content is
http://RailsForZombies.org
4. Recommendations for creating
•Make each episode a separate video, not one long
one. a
•If possible, don’t use slides
video with these your laptop microphone, use
a
USB Microphone like: http://amzn.to/eHTMSJ
•Seeing your face is more entertaining then just
watching code. Please insert yourself into the
content.
•Keynote allows you to “Record Slideshow”, which is
good for
pacing the timing of the slides (not audio though).
You can
then export video with that timing. You’d then
take this into
another video editor. (this is how you to delete this slid
Feel free export with
animations) content is available free on
This created by
If you need an editor suggestion: Screenflow
http://RailsForZombies.org
5. An Introduction to
Rails
Episode #1
This content is available free on created by
http://RailsForZombies.org
18. CRU
D
id status zombie
Zombie Challenge #1
Retrieve a hash of the tweet with id =
3
19. CRU
D
id status zombie
Zombie Challenge #1
Retrieve a hash of the tweet with id =
3
Result
b = { :status => "I just ate some delicious brains",
:zombie => "Jim" }
20. CRU
Hash D
Series of key value pairs
b = { :status => "I just ate some delicious brains",
:zombie => "Jim" }
21. CRU
Hash D
Series of key value pairs
b = { :status => "I just ate some delicious brains",
:zombie => "Jim" }
puts b[:status]
22. CRU
Hash D
Series of key value pairs
b = { :status => "I just ate some delicious brains",
:zombie => "Jim" }
puts b[:status]
"I just ate some delicious brains"
23. CRU
Hash D
Series of key value pairs
b = { :status => "I just ate some delicious brains",
:zombie => "Jim" }
puts b[:status]
"I just ate some delicious brains"
puts b[:zombie]
24. CRU
Hash D
Series of key value pairs
b = { :status => "I just ate some delicious brains",
:zombie => "Jim" }
puts b[:status]
"I just ate some delicious brains"
puts b[:zombie]
"Jim"
25. CRU
Hash D
Series of key value pairs
b = { :status => "I just ate some delicious brains",
:zombie => "Jim" }
puts b[:status]
"I just ate some delicious brains"
puts b[:zombie]
"Jim"
puts b[:zombie] + " said " + b[:status]
26. CRU
Hash D
Series of key value pairs
b = { :status => "I just ate some delicious brains",
:zombie => "Jim" }
puts b[:status]
"I just ate some delicious brains"
puts b[:zombie]
"Jim"
puts b[:zombie] + " said " + b[:status]
"Jim said I just ate some delicious brains"
27. CRU
Hash D
Series of key value pairs
b = { :status => "I just ate some delicious brains",
:zombie => "Jim" }
puts b[:status]
"I just ate some delicious brains"
puts b[:zombie]
"Jim"
puts b[:zombie] + " said " + b[:status]
"Jim said I just ate some delicious brains"
29. CRU
tweets D
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
30. CRU
tweets D
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
ombie Challenge #1
Retrieve a hash of the tweet with id = 3
31. CRU
tweets D
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
ombie Challenge #1
Retrieve a hash of the tweet with id = 3
Answer t = Tweet.find(3)
32. CRU
tweets D
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
ombie Challenge #1
Retrieve a hash of the tweet with id = 3
Answer t = Tweet.find(3)
puts t[:id]
33. CRU
tweets D
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
ombie Challenge #1
Retrieve a hash of the tweet with id = 3
Answer t = Tweet.find(3)
puts t[:id] 3
34. CRU
tweets D
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
ombie Challenge #1
Retrieve a hash of the tweet with id = 3
Answer t = Tweet.find(3)
puts t[:id] 3
puts t[:status]
35. CRU
tweets D
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
ombie Challenge #1
Retrieve a hash of the tweet with id = 3
Answer t = Tweet.find(3)
puts t[:id] 3
puts t[:status] "I just ate some delicious brains."
36. CRU
tweets D
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
ombie Challenge #1
Retrieve a hash of the tweet with id = 3
Answer t = Tweet.find(3)
puts t[:id] 3
puts t[:status] "I just ate some delicious brains."
puts t[:zombie]
37. CRU
tweets D
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
ombie Challenge #1
Retrieve a hash of the tweet with id = 3
Answer t = Tweet.find(3)
puts t[:id] 3
puts t[:status] "I just ate some delicious brains."
puts t[:zombie] "Jim"
38. CRU
t = Tweet.find(3)
D
puts t[:id]
puts t[:status]
puts t[:zombie]
39. CRU
t = Tweet.find(3)
D
puts t[:id] puts t.id
Sam
puts t[:status]
eA
puts t[:zombie]
s
40. CRU
t = Tweet.find(3)
D
puts t[:id] puts t.id
Sam
puts t[:status] puts t.status
eA
puts t[:zombie]
s
41. CRU
t = Tweet.find(3)
D
puts t[:id] puts t.id
Sam
puts t[:status] puts t.status
eA
puts t[:zombie] puts t.zombie
s
42. CRU
t = Tweet.find(3)
D
puts t[:id] puts t.id
Sam
puts t[:status] puts t.status
eA
puts t[:zombie] puts t.zombie
s
Answer puts t.id 3
puts t.status "I just ate some delicious brains."
puts t.zombie "Jim"
44. CRU
t = Tweet.find(3)
D
tweets
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
45. CRU
t = Tweet.find(3)
D
Pluralize
tweets
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
50. t = Tweet.new
Create t.status = "I <3 brains."
t.save
Read Tweet.find(3)
Update
Delete
51. t = Tweet.new
Create t.status = "I <3 brains."
t.save
Read Tweet.find(3)
t = Tweet.find(3)
Update t.zombie = "EyeballChomper"
t.save
Delete
52. t = Tweet.new
Create t.status = "I <3 brains."
t.save
Read Tweet.find(3)
t = Tweet.find(3)
Update t.zombie = "EyeballChomper"
t.save
t = Tweet.find(3)
Delete t.destroy
53. Create Syntax
t = Tweet.new
t.status = "I <3 brains."
t.zombie = "Jim"
t.save
54. Create Syntax
the id .
t = Tweet.new
n’t set a lly
e do anu
t.status = "I <3 brains."
tic e w s set m
t.zombie = "Jim" No et
t.save he id g or us.
T f
55. Create Syntax
the id .
t = Tweet.new
n’t set a lly
e do anu
t.status = "I <3 brains."
tic e w s set m
t.zombie = "Jim" No et
t.save he id g or us.
T f
Alternate Syntax
56. Create Syntax
the id .
t = Tweet.new
n’t set a lly
e do anu
t.status = "I <3 brains."
tic e w s set m
t.zombie = "Jim" No et
t.save he id g or us.
T f
Alternate Syntax
t = Tweet.new(:status => "I <3 brains", :zombie => "Jim")
t.save
57. Create Syntax
the id .
t = Tweet.new
n’t set a lly
e do anu
t.status = "I <3 brains."
tic e w s set m
t.zombie = "Jim" No et
t.save he id g or us.
T f
Alternate Syntax
t = Tweet.new(:status => "I <3 brains", :zombie => "Jim")
t.save
Tweet.create(:status => "I <3 brains", :zombie => "Jim")
59. Read Syntax
Tweet.find(2) # Returns a single item
60. Read Syntax
Tweet.find(2) # Returns a single item
Tweet.find(3, 4, 5) # Returns an array
61. Read Syntax
Tweet.find(2) # Returns a single item
Tweet.find(3, 4, 5) # Returns an array
Tweet.first # Returns the first tweet
62. Read Syntax
Tweet.find(2) # Returns a single item
Tweet.find(3, 4, 5) # Returns an array
Tweet.first # Returns the first tweet
Tweet.last # Returns the last tweet
63. Read Syntax
Tweet.find(2) # Returns a single item
Tweet.find(3, 4, 5) # Returns an array
Tweet.first # Returns the first tweet
Tweet.last # Returns the last tweet
Tweet.all # Returns all the tweets
64. Read Syntax
Tweet.find(2) # Returns a single item
Tweet.find(3, 4, 5) # Returns an array
Tweet.first # Returns the first tweet
Tweet.last # Returns the last tweet
Tweet.all # Returns all the tweets
Tweet.count # Returns number of tweets
65. Read Syntax
Tweet.find(2) # Returns a single item
Tweet.find(3, 4, 5) # Returns an array
Tweet.first # Returns the first tweet
Tweet.last # Returns the last tweet
Tweet.all # Returns all the tweets
Tweet.count # Returns number of tweets
Tweet.order(:zombie) # All ordered by zombie
66. Read Syntax
Tweet.find(2) # Returns a single item
Tweet.find(3, 4, 5) # Returns an array
Tweet.first # Returns the first tweet
Tweet.last # Returns the last tweet
Tweet.all # Returns all the tweets
Tweet.count # Returns number of tweets
Tweet.order(:zombie) # All ordered by zombie
Tweet.limit(10) # Only 10 tweets
67. Read Syntax
Tweet.find(2) # Returns a single item
Tweet.find(3, 4, 5) # Returns an array
Tweet.first # Returns the first tweet
Tweet.last # Returns the last tweet
Tweet.all # Returns all the tweets
Tweet.count # Returns number of tweets
Tweet.order(:zombie) # All ordered by zombie
Tweet.limit(10) # Only 10 tweets
Tweet.where(:zombie => "ash") # Only tweets by Ash
68. Read Syntax
Tweet.find(2) # Returns a single item
Tweet.find(3, 4, 5) # Returns an array
Tweet.first # Returns the first tweet
Tweet.last # Returns the last tweet
Tweet.all # Returns all the tweets
Tweet.count # Returns number of tweets
Tweet.order(:zombie) # All ordered by zombie
Tweet.limit(10) # Only 10 tweets
Tweet.where(:zombie => "ash") # Only tweets by Ash
Tweet.where(:zombie => "ash").order(:zombie).limit(10)
method chaining
69. Update Syntax
t = Tweet.find(3)
t.zombie = "EyeballChomper"
t.save
70. Update Syntax
t = Tweet.find(3)
t.zombie = "EyeballChomper"
t.save
t = Tweet.find(2)
t.attributes = {
:status => "Can I munch your eyeballs?",
:zombie => "EyeballChomper"
}
t.save
71. Update Syntax
t = Tweet.find(3)
t.zombie = "EyeballChomper"
t.save
t = Tweet.find(2)
t.attributes = {
:status => "Can I munch your eyeballs?",
:zombie => "EyeballChomper"
}
t.save
t = Tweet.find(2)
t.update_attributes(
:status => "Can I munch your eyeballs?",
:zombie => "EyeballChomper"
)
73. Delete Syntax
t = Tweet.find(2)
t.destroy
Tweet.find(2).destroy
74. Delete Syntax
t = Tweet.find(2)
t.destroy
Tweet.find(2).destroy
Tweet.destroy_all
75. Zombie
http://railsforzombies.org
Stop when you reach the video for Lab 2
Don’t worry about watching any of the videos
Download the slides so you can remember the syntax
76. An Introduction to
Rails
Episode #2
This content is available free on created by
http://RailsForZombies.org
80. Model
t = Tweet.find(3)
Tweet s
tweets
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
81. Model
t = Tweet.find(3)
Tweet s
?
tweets
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
82. Model
t = Tweet.find(3)
Tweet s
app/models/tweet.rb
class Tweet < ActiveRecord::Base
end
tweets
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
83. Model
Tweet s
app/models/tweet.rb
class Tweet < ActiveRecord::Base
end
tweets
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
84. Model
Tweet s
app/models/tweet.rb
class Tweet < ActiveRecord::Base
end
tweets
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
85. Model
Tweet s
app/models/tweet.rb
class Tweet < ActiveRecord::Base
end
Maps the class to the
tweets table
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
86. Model
Tweet s
app/models/tweet.rb
class Tweet < ActiveRecord::Base
end
Maps the class to the
tweets table
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
87. Model
app/models/tweet.rb
class Tweet < ActiveRecord::Base s
end
tweets
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
88. Model
app/models/tweet.rb
class Tweet < ActiveRecord::Base s
end
t = Tweet.find(3)
tweets
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
89. Model
app/models/tweet.rb
class Tweet < ActiveRecord::Base s
end
t = Tweet.find(3)
class
tweets
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
90. Model
app/models/tweet.rb
class Tweet < ActiveRecord::Base s
end
t = Tweet.find(3)
class
tweets
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
91. Model
app/models/tweet.rb
class Tweet < ActiveRecord::Base s
end
instance of Tweet t = Tweet.find(3)
Tweet #3
class
tweets
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
92. Validations?
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
93. Validations?
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
t = Tweet.new
t.save
94. Validations?
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
5
t = Tweet.new
t.save
95. Valida
tio
app/models/tweet.rb ns
class Tweet < ActiveRecord::Base
end
96. Valida
tio
app/models/tweet.rb ns
class Tweet < ActiveRecord::Base
validates_presence_of :status
end
97. Valida
tio
app/models/tweet.rb ns
class Tweet < ActiveRecord::Base
validates_presence_of :status
end
> t = Tweet.new
=> #<Tweet id: nil, status: nil, zombie: nil>
98. Valida
tio
app/models/tweet.rb ns
class Tweet < ActiveRecord::Base
validates_presence_of :status
end
> t = Tweet.new
=> #<Tweet id: nil, status: nil, zombie: nil>
> t.save
=> false
99. Valida
tio
app/models/tweet.rb ns
class Tweet < ActiveRecord::Base
validates_presence_of :status
end
> t = Tweet.new
=> #<Tweet id: nil, status: nil, zombie: nil>
> t.save
=> false
> t.errors
=> {:status=>["can't be blank"]}
100. Valida
tio
app/models/tweet.rb ns
class Tweet < ActiveRecord::Base
validates_presence_of :status
end
> t = Tweet.new
=> #<Tweet id: nil, status: nil, zombie: nil>
> t.save
=> false
> t.errors
=> {:status=>["can't be blank"]}
> t.errors[:status]
=> "can't be blank"
108. el a ti o nship s
Because they always travel in packs
109. Relatio
tweets
nship
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
110. Relatio
tweets
nship
id status zombie
1 Where can I get a good bite to eat? Ash
2 My left arm is missing, but I don't care. Bob
3 I just ate some delicious brains. Jim
4 OMG, my fingers turned green. #FML Ash
111. Relatio
tweets
nship
id status
1 Where can I get a good bite to eat?
2 My left arm is missing, but I don't care.
3 I just ate some delicious brains.
4 OMG, my fingers turned green. #FML
112. Relatio
tweets
nship
id status
1 Where can I get a good bite to eat?
2 My left arm is missing, but I don't care.
3 I just ate some delicious brains.
4 OMG, my fingers turned green. #FML
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
113. Relatio
tweets
nship
id status
1 Where can I get a good bite to eat?
2 My left arm is missing, but I don't care.
3 I just ate some delicious brains.
4 OMG, my fingers turned green. #FML
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
114. Relatio
tweets
nship
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
115. Relatio
tweets
nship
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
116. Relatio
tweets
nship
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
5 Your eyelids taste like bacon. 2
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
117. Relatio
tweets
nship
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
5 Your eyelids taste like bacon. 2
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
118. Relatio
tweets
nship
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
5 Your eyelids taste like bacon. 2
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
119. tweets
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
120. A Tweet
tweets
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
121. A Tweet belongs to
tweets
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
122. A Tweet belongs to a Zombie
tweets
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
123. A Tweet belongs to a Zombie
app/models/tweet.rb
class Tweet < ActiveRecord::Base
end
tweets
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
124. A Tweet belongs to a Zombie
app/models/tweet.rb
class Tweet < ActiveRecord::Base
belongs_to :zombie
end
Singular tweets
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
125. A Tweet belongs to a Zombie A Zombie
app/models/tweet.rb
class Tweet < ActiveRecord::Base
belongs_to :zombie
end
Singular tweets
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
126. A Tweet belongs to a Zombie A Zombie has many
app/models/tweet.rb
class Tweet < ActiveRecord::Base
belongs_to :zombie
end
Singular tweets
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
127. A Tweet belongs to a Zombie A Zombie has many Tweets
app/models/tweet.rb
class Tweet < ActiveRecord::Base
belongs_to :zombie
end
Singular tweets
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
128. A Tweet belongs to a Zombie A Zombie has many Tweets
app/models/tweet.rb app/models/zombie.rb
class Tweet < ActiveRecord::Base class Zombie < ActiveRecord::Base
belongs_to :zombie
end end
Singular tweets
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
129. A Tweet belongs to a Zombie A Zombie has many Tweets
app/models/tweet.rb app/models/zombie.rb
class Tweet < ActiveRecord::Base class Zombie < ActiveRecord::Base
belongs_to :zombie has_many :tweets
end end
Plural
Singular tweets
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care. 2
3 I just ate some delicious brains. 3
4 OMG, my fingers turned green. #FML 1
zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetery
2 Bob Chapel Hill Cemetery
3 Jim My Father’s Basement
157. Show a tweet
<% ... %>
Evaluate Ruby
<%= ... %>
Eval and print result
158. Show a tweet
<% ... %>
Evaluate Ruby
<%= ... %>
Eval and print result
/app/views/tweets/show.html.erb
<!DOCTYPE html>
<html>
<head><title>Twitter for Zombies</title></head>
<body>
<img src="/images/twitter.png" />
</body></html>
159. Show a tweet
<% ... %>
Evaluate Ruby
<%= ... %>
Eval and print result
/app/views/tweets/show.html.erb
<!DOCTYPE html>
<html>
<head><title>Twitter for Zombies</title></head>
<body>
<img src="/images/twitter.png" />
<% tweet = Tweet.find(1) %>
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
</body></html>
160. Show a tweet
<% ... %>
Evaluate Ruby
<%= ... %>
Eval and print result
/app/views/tweets/show.html.erb
<!DOCTYPE html>
<html>
<head><title>Twitter for Zombies</title></head>
<body>
<img src="/images/twitter.png" />
FYI, This code
<% tweet = Tweet.find(1) %>
sucks a little..
<h1><%= tweet.status %></h1> (for 2 reasons)
<p>Posted by <%= tweet.zombie.name %></p>
</body></html>
161. Show a tweet
<% ... %>
Evaluate Ruby
<%= ... %>
Eval and print result
/app/views/tweets/show.html.erb
<!DOCTYPE html>
<html>
<head><title>Twitter for Zombies</title></head>
<body>
<img src="/images/twitter.png" />
<% tweet = Tweet.find(1) %>
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
</body></html>
162. Show a tweet
/app/views/layouts/
application.html.erb
<!DOCTYPE html>
<html>
<head><title>Twitter for Zombies</title></head>
<body>
<img src="/images/twitter.png" />
</body></html>
/app/views/tweets/show.html.erb
<% tweet = Tweet.find(1) %>
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
163. Show a tweet
/app/views/layouts/
application.html.erb
<!DOCTYPE html>
<html>
<head><title>Twitter for Zombies</title></head>
<body>
<img src="/images/twitter.png" />
<%= yield %>
</body></html>
/app/views/tweets/show.html.erb
<% tweet = Tweet.find(1) %>
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
164. Views
zombie_twitter
app
views
zombies
List all tweets
tweets
index.html.erb
View a tweet
show.html.erb
165. Views
zombie_twitter
app
views
layouts
zombies
List all tweets
tweets
index.html.erb
View a tweet
show.html.erb
166. Views
zombie_twitter
app
views
The main layout
layouts
application.html.erb
zombies
List all tweets
tweets
index.html.erb
View a tweet
show.html.erb
177. Additional Layout Components
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
Includ
e d ef
ault J
S
<%= csrf_meta_tag %>
178. Additional Layout Components
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
Includ
zombie_twitter e d ef
ault J
public S
javascripts
<%= csrf_meta_tag %>
179. Additional Layout Components
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
Includ
zombie_twitter e d ef
ault J
public S
javascripts
Renders
<script Proto
src="/javascripts/prototype.js" type="text/javascript"></script>
<script type
src="/javascripts/effects.js" type="text/javascript"></script>
Javas
<script
Fram c r ip t
src="/javascripts/dragdrop.js" type="text/javascript"></script>
<script
<script ework
src="/javascripts/controls.js" type="text/javascript"></script>
src="/javascripts/rails.js" type="text/javascript"></script>
<script src="/javascripts/application.js" type="text/javascript"></script>
<%= csrf_meta_tag %>
181. Additional Layout Components
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
Zombie Hacker
<form Site
target="http://yoursite.co
m">
Think Your Site
comm
spam ent
182. Additional Layout Components
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
Zombie Hacker
<form Site
target="http://yoursite.co
m">
Think Your Site
comm
Renders spam ent
<meta name="csrf-param" content="authenticity_token"/>
<meta name="csrf-token" content="I+d..jI="/>
Automatically adds this to forms
184. Root path and images
http://ZombieTwitter.com/[something]
185. Root path and images
http://ZombieTwitter.com/[something]
zombie_twitter lic
ub to
public /p
in e go
xi sts rwis
stylesheets
I f e othe
javascripts
e it, Ra ils
images us
Example
<img src="/images/twitter.png" />
192. Adding a Link
/app/views/tweets/show.html.erb
bi ea
...
ez om
ak ink
<p>Posted by <%= tweet.zombie.name %></p>
M l
<%= link_to tweet.zombie.name , zombie_path(tweet.zombie) %>
Link Text Link Path (URL)
193. Adding a Link
/app/views/tweets/show.html.erb
bi ea
...
ez om
ak ink
<p>Posted by <%= tweet.zombie.name %></p>
M l
<%= link_to tweet.zombie.name , zombie_path(tweet.zombie) %>
Link Text Link Path (URL)
Renders <a href="/zombies/1">Ash</a>
194. Adding a Link
/app/views/tweets/show.html.erb
bi ea
...
ez om
ak ink
<p>Posted by <%= tweet.zombie.name %></p>
M l
<%= link_to tweet.zombie.name , zombie_path(tweet.zombie) %>
Link Text Link Path (URL)
Renders <a href="/zombies/1">Ash</a>
We can also write as
<%= link_to tweet.zombie.name, tweet.zombie %>
Link Text Object to Show
195.
196. Method
link_to with it?
y ou use
ons can
W hat opti
197. Method
link_to with it?
y ou use
ons can
W hat opti
1. Look in the source
198. Method
link_to with it?
y ou use
ons can
W hat opti
1. Look in the source
Command Line
199. Method
link_to with it?
y ou use
ons can
W hat opti
1. Look in the source
Command Line
git clone http://github.com/rails/rails.git
200. Method
link_to with it?
y ou use
ons can
W hat opti
1. Look in the source
Command Line
git clone http://github.com/rails/rails.git
cd rails
201. Method
link_to with it?
y ou use
ons can
W hat opti
1. Look in the source
Command Line
git clone http://github.com/rails/rails.git
cd rails
Open your editor and search for “def link_to”
202. Method
link_to with it?
y ou use
ions can
W hat op t
2. Look at
api.rubyonrails.org
(and search for link_to)
215. Views
zombie_twitter
app
views
The main layout
layouts
application.html.erb
zombies
List all tweets
tweets
index.html.erb
View a tweet
show.html.erb
245. All links for Tweets
<%= link_to "<link text>", <code> %>
246. All links for Tweets
<%= link_to "<link text>", <code> %>
Action Code The URL Generated
List all tweets tweets_path /tweets
New tweet form new_tweet_path /tweets/new
247. All links for Tweets
<%= link_to "<link text>", <code> %>
Action Code The URL Generated
List all tweets tweets_path /tweets
New tweet form new_tweet_path /tweets/new
248. All links for Tweets
<%= link_to "<link text>", <code> %>
Action Code The URL Generated
List all tweets tweets_path /tweets
New tweet form new_tweet_path /tweets/new
249. All links for Tweets
<%= link_to "<link text>", <code> %>
Action Code The URL Generated
List all tweets tweets_path /tweets
New tweet form new_tweet_path /tweets/new
These paths n
tweet = Tweet.find(1) eed a
tweet
250. All links for Tweets
<%= link_to "<link text>", <code> %>
Action Code The URL Generated
List all tweets tweets_path /tweets
New tweet form new_tweet_path /tweets/new
These paths n
tweet = Tweet.find(1) eed a
tweet
Action Code The URL Generated
Show a tweet tweet /tweets/1
Edit a tweet edit_tweet_path(tweet) /tweets/1/edit
Delete a tweet tweet, :method => :delete /tweets/1
251. All links for Tweets
<%= link_to "<link text>", <code> %>
Action Code The URL Generated
List all tweets tweets_path /tweets
New tweet form new_tweet_path /tweets/new
These paths n
tweet = Tweet.find(1) eed a
tweet
Action Code The URL Generated
Show a tweet tweet /tweets/1
Edit a tweet edit_tweet_path(tweet) /tweets/1/edit
Delete a tweet tweet, :method => :delete /tweets/1
252. All links for Tweets
<%= link_to "<link text>", <code> %>
Action Code The URL Generated
List all tweets tweets_path /tweets
New tweet form new_tweet_path /tweets/new
These paths n
tweet = Tweet.find(1) eed a
tweet
Action Code The URL Generated
Show a tweet tweet /tweets/1
Edit a tweet edit_tweet_path(tweet) /tweets/1/edit
Delete a tweet tweet, :method => :delete /tweets/1
266. Request
/tweets/1
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
...
end
/app/views/tweets/show.html.erb
<% tweet = Tweet.find(1) %>
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
267. Request
/tweets/1
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
end
end
/app/views/tweets/show.html.erb
<% tweet = Tweet.find(1) %>
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
268. Request
/tweets/1
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
end
end
/app/views/tweets/show.html.erb
show
<% tweet = Tweet.find(1) %>
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
269. Request
/tweets/1
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
end
end
/app/views/tweets/show.html.erb
<% tweet = Tweet.find(1) %>
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
270. Request
/tweets/1
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
tweet = Tweet.find(1)
end
end
/app/views/tweets/show.html.erb
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
271. Request
/tweets/1
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
tweet = Tweet.find(1)
end
end
/app/views/tweets/show.html.erb
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
272. Request
/tweets/1
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
tweet = Tweet.find(1)
end
end
/app/views/tweets/show.html.erb
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
273. Request
/tweets/1
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
tweet = Tweet.find(1)
end
end
/app/views/tweets/show.html.erb
What about
<h1><%= tweet.status %></h1> variable scope?
<p>Posted by <%= tweet.zombie.name %></p>
274. Instance Variable Request
/tweets/1
@
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
tweet = Tweet.find(1)
end
end
/app/views/tweets/show.html.erb
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
275. Instance Variable Request
/tweets/1
@
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
@ tweet = Tweet.find(1)
end
end
/app/views/tweets/show.html.erb
<h1><%= tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
276. Instance Variable Request
/tweets/1
@
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
@ tweet = Tweet.find(1)
end
end
/app/views/tweets/show.html.erb
<h1><%= @ tweet.status %></h1>
<p>Posted by <%= tweet.zombie.name %></p>
277. Instance Variable Request
/tweets/1
@
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
@ tweet = Tweet.find(1)
end
end
/app/views/tweets/show.html.erb
<h1><%= @ tweet.status %></h1>
<p>Posted by <%= @ tweet.zombie.name %></p>
278. Render Request
/tweets/1
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
@ tweet = Tweet.find(1)
end
end
/app/views/tweets/status.html.erb
<h1><%= @ tweet.status %></h1>
<p>Posted by <%= @ tweet.zombie.name %></p>
279. Render Request
/tweets/1
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
@ tweet = Tweet.find(1)
end
end
/app/views/tweets/status.html.erb
<h1><%= @ tweet.status %></h1>
<p>Posted by <%= @ tweet.zombie.name %></p>
280. Render Request
/tweets/1
/app/controllers/tweets_controller.rb
class TweetsController < ApplicationController
def show
@ tweet = Tweet.find(1)
end
end
/app/views/tweets/status.html.erb
<h1><%= @ tweet.status %></h1>
<p>Posted by <%= @ tweet.zombie.name %></p>