Skip to content

Instantly share code, notes, and snippets.

@ryanmenzer
Last active December 24, 2015 18:29
Show Gist options
  • Save ryanmenzer/6843138 to your computer and use it in GitHub Desktop.
Save ryanmenzer/6843138 to your computer and use it in GitHub Desktop.
from "Rails the Sinatra Way", deaf grandma not speaking to me!
<div class="container">
<h1>Deaf Grandma</h1>
<% if @grandma %>
<p>Grandma says: "<span id="grandma_says"><%= @grandma %></span>"</p>
<% end %>
<form action="/grandma" method="post">
Say something to Grandma:
<br>
<input type="text" name="user_input">
<input type="submit" value="Say it!">
</form>
</div>
class PagesController < ApplicationController
def index
@grandma = params[:grandma]
end
def show
input = params[:user_input]
if input == input.upcase && input != ""
@grandma = "NOT SINCE 1983!"
else
@grandma = "SPEAK UP, SONNY!"
end
render :index
end
end
LearningRails::Application.routes.draw do
get '/' => 'pages#index'
match '/grandma' => 'pages#show'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment