Skip to content

Commit

Permalink
Stoopid coach exercise completed
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoapel committed May 20, 2019
1 parent e756286 commit a21c164
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/questions.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/questions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the questions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
16 changes: 16 additions & 0 deletions app/controllers/questions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class QuestionsController < ApplicationController
def ask

end

def answear
@question = params[:question]
if @question.include?("?")
@answear = "Silly question, get dressed and go to work!"
elsif @question == "I am going to work"
@answear = "Great!"
else
@answear = "I don't care, get dressed and go to work!"
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/questions_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module QuestionsHelper
end
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</head>

<body>
<h1>Stupid Coaching</h1>
<%= yield %>
</body>
</html>
6 changes: 6 additions & 0 deletions app/views/questions/answear.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Answear</h1>

<p><%= @question %></p>

<p><%= @answear %></p>

6 changes: 6 additions & 0 deletions app/views/questions/ask.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Questions</h1>
<form action="/answear" method="get">
<input type="text" name="question" placeholder="Whats your question?">
<input type="submit" value="Ask!">
</form>

2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Rails.application.routes.draw do
get 'ask', to: 'questions#ask', as: :ask
get 'answear', to: 'questions#answear', as: :answear
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
14 changes: 14 additions & 0 deletions test/controllers/questions_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'test_helper'

class QuestionsControllerTest < ActionDispatch::IntegrationTest
test "should get ask" do
get questions_ask_url
assert_response :success
end

test "should get answear" do
get questions_answear_url
assert_response :success
end

end

0 comments on commit a21c164

Please sign in to comment.