Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix purchase time to datetime and add market show page #4

Merged
merged 1 commit into from
Oct 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions app/controllers/markets_controller.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
class MarketsController < ApplicationController
def index
@markets = Market.all
end

def show
@mymarket = Market.find(params[:id])
if @mymarket == nil
render :file => 'public/404.html', :status => :not_found
end
end

# would I need to write a find method... to show that once clicked.. you can see the details of each individual market.



def new

end

def create
end

def show
@my
@mymarket=Market.find(params[:id])
end

def edit
Expand Down
18 changes: 0 additions & 18 deletions app/views/markets/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,2 @@
<h1>Markets#index</h1>
<p>Find me in app/views/markets/index.html.erb</p>
<% @markets.each do |market| %>

<%= link_to(market[:name],show_path(market[:id]))%>
<%= " #{market.city}, #{market.state}" %></p>
<% end %>
<!-- <div>
above changed it to see if would work when phrased like tasklist
<ul>
<% @markets.each do |market| %>
<li>Market Name: <%=market[:name] %></li>
<li>Address: <%=market.address %></li>
<li>City: <%=market.city %></li>
<li>County: <%=market.county %></li>
<li>State: <%=market.state %></li>
<li>Zip: <%=market.zip %></li>
</ul>
<% end %>
</div> -->
19 changes: 5 additions & 14 deletions app/views/markets/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
<h1>Markets#show</h1>
<section>
<p>id: <%= @mymarket.id %></p>
<p>name: <%= @mymarket.name %></p>
<p>address: <%=@mymarket.address %> <%=@mymarket.city%> <%=@mymarket.county%> <%=@mymarket.state%>, <%=@mymarket.zip%></p>
<section>
<p>Find me in app/views/markets/show.html.erb</p>

<h1>Market Details</h1>
<article class="">
<ul>
<% @params %>
<li>Market Id: <%=@mymarket[:id] %></li>
<li>Market name: <%=@mymarket[:name] %></li>
<!-- <li>Address: <%=@mymarket.address %></li>
<li>City: <%=@mymarket.city%></li>
<li>County: <%=@mymarket.county %></li>
<li>State: <%=@mymarket.state %></li>
<li>Zip: <%=@mymarket.zip %></li> -->
</ul>
</article>
8 changes: 4 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Rails.application.routes.draw do
root to: 'markets#index'

get 'products/index'

get 'products/new'
Expand Down Expand Up @@ -35,15 +37,13 @@

get 'vendors/destroy'

###### Markets Routes ######

get 'markets/index' => 'markets#index', as: 'index'
get 'markets/index'

get 'markets/new'

get 'markets/create'

get 'markets/show' => 'markets#show', as: 'show'
get 'markets/show/:id' => 'markets#show', as: 'markets_show'

get 'markets/edit'

Expand Down
4 changes: 3 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@
end

CSV.foreach('seed_csvs/sales.csv') do |csv_obj|
Sale.create(id: csv_obj[0].to_i, amount: csv_obj[1].to_i, purchase_time: csv_obj[2], vendor_id: csv_obj[3].to_i, product_id: csv_obj[4].to_i)
Sale.create(id: csv_obj[0].to_i, amount: csv_obj[1].to_i, purchase_time: DateTime.strptime(csv_obj[2], "%Y-%m-%d %H:%M:%S"),
vendor_id: csv_obj[3].to_i, product_id: csv_obj[4].to_i)
end