Challenges Routes, Views, Controllers
As a user, I can visit a custom landing page at localhost:3000.
def custom render html: "This is an awesome custom page" end
def custom
render html: "This is an awesome custom page"
end
As a user, I can see the names of my team members as hyperlinks on the landing page.
def David render html: "Hello" end def Lyssa render html: "Sweet" end
root 'main#custom' get '/custom' => 'main#custom' get '/David' => 'main#David' get '/Lyssa' => 'main#Lyssa' end
As a user, I can click on each team member's name and be taken to a page that displays a list of that team member's top three things. (Could be top three restaurants, activities, books, video games, hiking locations, beaches, doughnut shoppes, movies, etc.)
- Coffee
- Cats
- Cookies
- Food
- Travel
- Sports
def David end def Lyssa end
Params
As a user, I can visit a page called cubed that takes a number as a param and displays that number cubed.
def cubed @cubed = params[:cubed] @results = params[:cubed].to_i * params[:cubed].to_i * params[:cubed].to_i
end
<%= link_to "cubed", "/cubed" %>get '/cubed/:cubed' => 'main#cubed'
<%= @cubed %>
Your number cubed is <%= @results %>
As a user, I can visit a page called evenly that takes two numbers as params and displays whether or not the first number is evenly divisible by the second.
def evenly @evenly = params[:num1], params[:num2] if params[:num1].to_i % params[:num2].to_i == 0 @is_even = "Is evenly divisable" else @is_even = "Is NOT evenly divisable" end end
<%= link_to "evenly", "/evenly" %>
get '/evenly/:num1/:num2' => 'main#evenly'
<%= @num1 %> <%= @num2 %>
<%= @is_even %> As a user, I can visit a page called palindrome that takes a string as a param and displays whether it is a palindrome (the same word forward and backward).
def palindrome @palindrome = params[:str] if params[:str].downcase == params[:str].downcase.reverse @is_palindrome = 'This is a palindrome' else @is_palindrome = 'This is NOT a palindrome' end end
<%= @str %>
<%= @is_palindrome %>
get '/palindrome/:str' => 'main#palindrome'
As a user, I can visit a page called madlib that takes params of a noun, verb, adjective, adverb, and displays a short silly story.
def madlib @mablib = params[:noun], params[:verb], params[:adj], params[:adv] @noun = params[:noun] @verb = params[:verb] @adj = params[:adj] @adv = params[:adv] end
<%= link_to "madlib", "/madlib" %>
<%= @madlib %>
There once was a <%= @noun %> who was doing <%= @verb %>. She loved <%= @adj %> ponies. The ponies were jumping <%= @adv %>.
get '/madlib/:noun/:verb/:adj/:adv' => 'main#madlib'