Permalink
Browse files

fix @price blowup

  • Loading branch information...
1 parent 3611d15 commit 6022b48f71a0dd7ee155750fff87a67473301ab0 Josh Crews committed Mar 5, 2012
View
2 app/controllers/commodities_controller.rb
@@ -1,7 +1,7 @@
class CommoditiesController < ApplicationController
def show
@commodity = Commodity.find(params[:id])
- @price = Price.find_by_commodity_id(params[:all])
end
+
#binding.pry
end
View
1 app/models/commodity.rb
@@ -1,2 +1,3 @@
class Commodity < ActiveRecord::Base
+ has_many :prices
end
View
30 app/views/commodities/show.html.erb
@@ -1,18 +1,20 @@
<h1>Commodities#show</h1>
<p>Find me in app/views/commodities/show.html.erb</p>
-<%= @price.inspect %>
-
<h3>Prices for <%= @commodity.name %></h3>
- <p>price_quality = good </p>
- <p>Price Type = government </p>
-
- <p>Farm gate high (<%= @commodity.farm_gate_unit %>) = <%= @price.farm_gate_high %></p>
- <p>Farm gate low (<%= @commodity.farm_gate_unit %>) = <%= @price.farm_gate_low %></p>
- <p>Delivered high (<%= @commodity.delivered_unit %>) = 9</p>
- <p>Delivered low (<%= @commodity.delivered_unit %>) = 7</p>
- <p>Wholesale high (<%= @commodity.wholesale_unit %>) = 14</p>
- <p>Wholesale low (<%= @commodity.wholesale_unit %>) = 13</p>
- <p>Retail high (<%= @commodity.retail_unit %>) = 19</p>
- <p>Retail low (<%= @commodity.retail_unit %>) = 17</p>
- <p>Date: "01/01/1990"</p>
+
+<% @commodity.prices.each do |price| %>
+ <p>price_quality = good </p>
+ <p>Price Type = government </p>
+
+ <p>Farm gate high (<%= price.farm_gate_unit %>) = <%= price.farm_gate_high %></p>
+ <p>Farm gate low (<%= price.farm_gate_unit %>) = <%= price.farm_gate_low %></p>
+ <p>Delivered high (<%= price.delivered_unit %>) = 9</p>
+ <p>Delivered low (<%= price.delivered_unit %>) = 7</p>
+ <p>Wholesale high (<%= price.wholesale_unit %>) = 14</p>
+ <p>Wholesale low (<%= price.wholesale_unit %>) = 13</p>
+ <p>Retail high (<%= price.retail_unit %>) = 19</p>
+ <p>Retail low (<%= price.retail_unit %>) = 17</p>
+ <p>Date: "01/01/1990"</p>
+<% end %>
+
View
1 features/user_can_see_two_prices.feature
@@ -1,3 +1,4 @@
+@focus
Feature: As a user, I want to see all prices for corn so that I can see the trend and
and make intelligent decisions on when to sell.

0 comments on commit 6022b48

Please sign in to comment.