Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixing merge

  • Loading branch information...
commit 86736885fac728211afce0e3c01a1cdf114efebc 2 parents fd6e196 + a8bee12
@dladowitz dladowitz authored
View
9 app/controllers/guesses_controller.rb
@@ -1,5 +1,12 @@
class GuessesController < ApplicationController
def new
- @guess = Guess.new
+
end
+
+ def create
+ @height = params[:height]
+ @weight = params[:weight]
+ redirect_to new_guess_path
+ end
+
end
View
6 app/models/guess.rb
@@ -1,4 +1,10 @@
class Guess < ActiveRecord::Base
attr_accessible :total_female_height, :total_female_weight, :total_male_height, :total_male_weight
+
+
end
+<<<<<<< HEAD
+=======
+#
+>>>>>>> a8bee1229962ed42dd89ca41a343dbf365cee47b
View
19 app/models/population_state.rb
@@ -0,0 +1,19 @@
+class PopulationState < ActiveRecord::Base
+ attr_accessible :total_female_height, :total_female_weight, :total_females, :total_male_height, :total_male_weight, :total_males, :variance_height, :variance_weight
+
+
+
+ def total_probability_male
+ total_males/Person.count
+ end
+
+ def variance_height_male
+ heights_male = Person.all.collect {|person| Person.height}
+ 1/(total_males - 1) * heights_male.inject {|sum, height| sum + (height - total_male_height/total_males)**2}
+ end
+
+ def probability_height_male
+
+
+
+end
View
19 app/views/guesses/new.html.erb
@@ -1,12 +1,16 @@
<h1>Gender Guess</h1>
-<div class="row">
- <div class="span6 offset3">
- <%= form_for(@guess) do |f| %>
+<%= form_tag guesses_path do %>
+ <%=label_tag 'height (inches)' %>
+ <%=text_field_tag 'height' %>
- <%= f.label :name %>
- <%= f.text_field :name %>
+ <%=label_tag 'weight (lbs)' %>
+ <%=text_field_tag 'weight' %>
+
+ <div><%= submit_tag 'Save' %></div>
+<% end %>
+<<<<<<< HEAD
<%= f.label :height %>
<%= f.text_field :height %>
@@ -18,4 +22,7 @@
<%= f.submit "Ask Miss Clea to Guess", class: "btn btn-large btn-primary" %>
<% end %>
</div>
-</div>
+</div>
+=======
+
+>>>>>>> a8bee1229962ed42dd89ca41a343dbf365cee47b
View
11 app/views/guesses/new.html.haml
@@ -0,0 +1,11 @@
+%h Gender Guess
+
+= form_tag guesses_path do
+ =label_tag 'height (inches)'
+ =text_field_tag 'height'
+
+ =label_tag 'weight (lbs)'
+ =text_field_tag 'weight'
+
+ = submit_tag 'Save'
+end
View
9 db/migrate/20121005004353_remove_total_male_height_from_guess.rb
@@ -0,0 +1,9 @@
+class RemoveTotalMaleHeightFromGuess < ActiveRecord::Migration
+ def up
+ remove_column :guesses, :total_male_height
+ end
+
+ def down
+ add_column :guesses, :total_male_height, :integer
+ end
+end
View
9 db/migrate/20121005005003_remove_total_male_weight_from_guess.rb
@@ -0,0 +1,9 @@
+class RemoveTotalMaleWeightFromGuess < ActiveRecord::Migration
+ def up
+ remove_column :guesses, :total_male_weight
+ end
+
+ def down
+ add_column :guesses, :total_male_weight, :integer
+ end
+end
View
9 db/migrate/20121005005118_remove_total_female_height_from_guess.rb
@@ -0,0 +1,9 @@
+class RemoveTotalFemaleHeightFromGuess < ActiveRecord::Migration
+ def up
+ remove_column :guesses, :total_female_height
+ end
+
+ def down
+ add_column :guesses, :total_female_height, :integer
+ end
+end
View
9 db/migrate/20121005005200_remove_total_female_weight_from_guess.rb
@@ -0,0 +1,9 @@
+class RemoveTotalFemaleWeightFromGuess < ActiveRecord::Migration
+ def up
+ remove_column :guesses, :total_female_weight
+ end
+
+ def down
+ add_column :guesses, :total_female_weight, :integer
+ end
+end
View
5 db/migrate/20121005005630_add_name_to_guess.rb
@@ -0,0 +1,5 @@
+class AddNameToGuess < ActiveRecord::Migration
+ def change
+ add_column :guesses, :name, :string
+ end
+end
View
5 db/migrate/20121005005739_add_height_to_guess.rb
@@ -0,0 +1,5 @@
+class AddHeightToGuess < ActiveRecord::Migration
+ def change
+ add_column :guesses, :height, :integer
+ end
+end
View
5 db/migrate/20121005005814_add_weight_to_guess.rb
@@ -0,0 +1,5 @@
+class AddWeightToGuess < ActiveRecord::Migration
+ def change
+ add_column :guesses, :weight, :integer
+ end
+end
View
5 db/migrate/20121005005936_add_sex_to_guess.rb
@@ -0,0 +1,5 @@
+class AddSexToGuess < ActiveRecord::Migration
+ def change
+ add_column :guesses, :sex, :string
+ end
+end
View
15 db/migrate/20121005020913_create_population_states.rb
@@ -0,0 +1,15 @@
+class CreatePopulationStates < ActiveRecord::Migration
+ def change
+ create_table :population_states do |t|
+ t.integer :total_males
+ t.integer :total_females
+ t.integer :total_male_height
+ t.integer :total_female_height
+ t.integer :total_male_weight
+ t.integer :total_female_weight
+ t.float :variance_height
+ t.float :variance_weight
+ t.timestamps
+ end
+ end
+end
View
27 db/schema.rb
@@ -11,15 +11,15 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20121004215154) do
+ActiveRecord::Schema.define(:version => 20121005020913) do
create_table "guesses", :force => true do |t|
- t.integer "total_male_height"
- t.integer "total_male_weight"
- t.integer "total_female_height"
- t.integer "total_female_weight"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.string "name"
+ t.integer "height"
+ t.integer "weight"
+ t.string "sex"
end
create_table "people", :force => true do |t|
@@ -31,4 +31,17 @@
t.datetime "updated_at", :null => false
end
+ create_table "population_states", :force => true do |t|
+ t.integer "total_males"
+ t.integer "total_females"
+ t.integer "total_male_height"
+ t.integer "total_female_height"
+ t.integer "total_male_weight"
+ t.integer "total_female_weight"
+ t.float "variance_height"
+ t.float "variance_weight"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
end
View
5 spec/models/population_state_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe PopulationState do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.