Model | View | Controller |
---|---|---|
Logic | Front-End | Middleman |
Brains | HTML | |
CSS | ||
Forms | ||
ERB* | ||
Chef | Guest | Waiter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Players | |
class Computer < Player | |
def move(board) | |
if board.cells.count{|square| square != " " } == 0 | |
"1" | |
elsif board.cells.count{|square| square != " " } == 1 | |
board.cells.find_index("X") == 4 ? "1" : "5" | |
else | |
possible_moves = ["1", "2", "3", "4", "5", "6", "7", "8", "9"] | |
valid_moves = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="social-icon-container"> | |
<a href="https://twitter.com/empireofryan"><img class="social-icon" src="../assets/img/twitter-icon.png"></a> | |
<a href="https://www.linkedin.com/in/ryan-johnson-321629ab"><img class="social-icon" src="../assets/img/linkedin-icon.png"></a> | |
<a href="https://github.com/empireofryan"><img class="social-icon" src="../assets/img/github-icon.png"></a> | |
<a href="https://www.youtube.com/watch?v=C22ufOqDyaE"><img class="social-icon" src="../assets/img/rss-icon.png"></a> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
social = doc.css(".social-icon-container a") | |
social.each do |link| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MeetupsAround::CLI | |
attr_reader :todays_date | |
def call | |
@todays_date = "Saturday, March 25" | |
input_zipcode | |
input_radius | |
list_meetups | |
again? | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
meetups.each.with_index(1) do |meetup, i| | |
puts "#{i}. #{meetup.time} - #{meetup.group} - #{meetup.event} - #{meetup.attendees}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def initialize(h) | |
h.each {|k,v| public_send("#{k}=",v)} | |
end |
Let's say we have a controller action:
get '/' do erb :index end
>When the above controller action is triggered and the erb
method is called, it looks to see if there is a view titled layout.erb
. If that file exists, it loads that content around the desired erb file, in this case index.erb
.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Failures: | |
1) App POST /teams submits the form | |
Failure/Error: click_button 'submit' | |
TypeError: | |
expected Hash (got String) for param `name' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Create a Team and Heroes!</h1> | |
<form action="/teams" method="POST"> | |
<p>Team Name: <input type="text" name="team[name]"></p> | |
<p>Team Motto: <input type="text" name="team[motto]"></p> | |
<h2>Hero 1</h2> | |
<p>Hero's Name: <input id="member1_name" type="text" name="team[name][hero][][name]"></p> | |
<p>Hero's Power: <input id="member1_power" type="text" name="team[name][hero][][power]"></p> | |
<p>Hero's Biography: <input id="member1_bio" type="text" name="team[name][hero][][bio]"></p> | |
<h2>Hero 2</h2> | |
<p>Hero's Name: <input id="member2_name" type="text" name="team[name][hero][][name]"></p> |