Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added index and show views for Guess

  • Loading branch information...
commit 450bbd236db2a30eddd64e96412f24b76f00c58b 1 parent d03a5df
David Ladowitz authored
13  app/controllers/guesses_controller.rb
... ...
@@ -1,11 +1,22 @@
1 1
 class GuessesController < ApplicationController
  2
+
  3
+  def index
  4
+	@guesses = Guess.all
  5
+  end
  6
+
2 7
   def new
3 8
   	@guess = Guess.new
4 9
   end
5 10
 
6 11
   def create
7 12
 	@guess = Guess.create(params[:guess])
8  
-  	redirect_to new_guess_path
  13
+  	redirect_to @guess
9 14
   end
10 15
 
  16
+  def show
  17
+  	@guess = Guess.find(params[:id])
  18
+  	@pop_state = PopulationState.find(1)
  19
+  end
  20
+
  21
+
11 22
 end
25  app/views/guesses/index.html.haml
... ...
@@ -0,0 +1,25 @@
  1
+%h3 Miss Cleo's past perdictions
  2
+
  3
+%table.table-striped#guess_table
  4
+  %thead
  5
+    %tr
  6
+      %th Name
  7
+      %th Height
  8
+      %th Weight
  9
+      %th Prediction
  10
+
  11
+  - @guesses.each do |guess|
  12
+    %tr
  13
+      %td= guess.name
  14
+      %td= guess.height
  15
+      %td= guess.weight
  16
+      %td= guess.sex
  17
+      %td
  18
+        .span.label.label-success
  19
+          = link_to 'View', guess
  20
+     
  21
+
  22
+%br
  23
+
  24
+.span.label.label-inverse#person_button
  25
+  = link_to 'New Guess', new_guess_path
18  app/views/guesses/show.html.haml
... ...
@@ -0,0 +1,18 @@
  1
+%p#notice= notice
  2
+
  3
+%p
  4
+  %b Name:
  5
+  = @guess.name
  6
+%p
  7
+  %b Height:
  8
+  = @guess.height
  9
+%p
  10
+  %b Weight:
  11
+  = @guess.weight
  12
+%p
  13
+  %b Miss Cleo thinks this person is a:
  14
+  = @pop_state.guess
  15
+  
  16
+
  17
+
  18
+= link_to 'Back', new_guess_path
7  app/views/layouts/application.html.erb
@@ -13,8 +13,11 @@
13 13
           <%= link_to "Miss Cleo", root_path, class: 'brand' %>
14 14
         <ul class="nav">
15 15
 
16  
-          <li class="dropdown">
17  
-            <%= link_to "Guess", new_guess_path %>
  16
+          <li>
  17
+            <%= link_to "New Guess", new_guess_path %>
  18
+          </li>
  19
+          <li >
  20
+            <%= link_to "Past Guesses", guesses_path %>
18 21
           </li>
19 22
         </ul>
20 23
       </div>

0 notes on commit 450bbd2

Please sign in to comment.
Something went wrong with that request. Please try again.