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

Item create method passing #13

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
4fbf10d
gemfile, .env/gitignore, and config/initializers/omniauth files created
canaanwest Oct 17, 2017
3ffb1a7
created category model, installed awesome_print, removed foundation v…
murog Oct 18, 2017
ba501a2
created product model
murog Oct 18, 2017
12d533d
created user model
murog Oct 18, 2017
ca42398
created entry model
murog Oct 18, 2017
432e192
created reveiw model
murog Oct 18, 2017
4701c5e
created order model
murog Oct 18, 2017
5ee12bc
created billing datum model
murog Oct 18, 2017
0f51c91
created controllers for each model
murog Oct 18, 2017
0753a3d
created MainPage controller
murog Oct 18, 2017
64c8630
added foreign keys to models
murog Oct 18, 2017
6370e1e
renamed entries to items, deleted entries model and controller compon…
murog Oct 18, 2017
9532d75
created item model
murog Oct 18, 2017
422c42c
created orderproduct table with foreign keys, updated order_prouct an…
murog Oct 18, 2017
6159923
created categories products join table, updated category and product …
murog Oct 18, 2017
cabe56c
added order_product, product, review and user validations
murog Oct 18, 2017
f6644c6
added validations to billing datum, category, item
murog Oct 18, 2017
5d90927
add session id to order, changed default values for items purchase an…
murog Oct 18, 2017
f8d423f
Reviews controller methods completed
Oct 18, 2017
9365d1b
updated review controller private method
Oct 18, 2017
856b9a2
Merge branch 'master' of https://github.com/canaanwest/betsy
Oct 18, 2017
07c9c89
yml files set up with appropriate categories
canaanwest Oct 18, 2017
b8e8ba4
added flash info to the application.html.erb
Oct 18, 2017
d9a6509
updated validations for category order order_product and product
murog Oct 18, 2017
e60e9b2
added reference of billing datum to user, updated belongs_to relation…
murog Oct 18, 2017
e7447de
change to redirect
Oct 18, 2017
d9befa9
Merge branch 'master' of https://github.com/canaanwest/betsy
murog Oct 18, 2017
4e9e4c7
fixed typo in product model
murog Oct 18, 2017
7331063
Merge branch 'gm-verify-validations'
murog Oct 18, 2017
e1ebeb4
reviews fixture
canaanwest Oct 18, 2017
bb0f056
fixed belong_to order relationship in item to be optional
murog Oct 18, 2017
b10dc3c
added model data as separate csv files and populated the seeds.rb file
julmeier Oct 18, 2017
df14d8f
Merge branch 'master' of https://github.com/canaanwest/betsy
julmeier Oct 18, 2017
78bfac9
yml files populated
canaanwest Oct 18, 2017
89a2bf9
routes and nested routes completed
Oct 18, 2017
d4cb7ee
Merge branch 'routes_and_resources'
Oct 18, 2017
9337b7f
removed symbols from items.yml
murog Oct 18, 2017
7d1fb56
Merge pull request #1 from canaanwest/testing-fixtures
murog Oct 18, 2017
5c11692
updated to root to for methods
Oct 18, 2017
42cd24e
Merge branch 'reviews_controller_MM'
Oct 18, 2017
aa0931a
Merge branch 'master' of https://github.com/canaanwest/betsy
Oct 18, 2017
d3f3523
moved seed data into a folder
murog Oct 18, 2017
1d8c433
moved user seeds into seed data folder
murog Oct 18, 2017
e5070b2
added billing tests for create, new, index
canaanwest Oct 18, 2017
f2010c5
moved user seeds
murog Oct 18, 2017
baf12fc
billing_data methods complteted(first walk through)
Oct 18, 2017
5b532f6
review belongs to user set as optional
murog Oct 18, 2017
68086a9
Merge branch 'billing_data_controller_methods'
Oct 18, 2017
af5715f
created users controller
Oct 18, 2017
bd1062c
created structure for reviews_controller_test. Will push and move on …
julmeier Oct 18, 2017
ad061bc
Merge branch 'master' of https://github.com/canaanwest/betsy into JM/…
julmeier Oct 18, 2017
06272c7
product model test validations for name and price
canaanwest Oct 19, 2017
4f30bf2
Manually created user views.
Oct 19, 2017
3f9e58e
Manually created user controller test file.
Oct 19, 2017
494613f
finishing up validations for products
canaanwest Oct 19, 2017
3b15057
Fixing seed data formatting
canaanwest Oct 19, 2017
8b8c7f9
updates and model tests
Oct 19, 2017
20c9e5e
Added CSV files & Fixed merge cnflt
canaanwest Oct 19, 2017
41c66d6
Merge branch 'mm/users_controller_tests_and_methods'
Oct 19, 2017
51fe814
changed category seeds
julmeier Oct 19, 2017
269581e
modifications to controller
canaanwest Oct 19, 2017
dd6f66b
user model tests passing
Oct 19, 2017
88f9217
Fixing merge conflict in CSV (currently all commented out)
canaanwest Oct 19, 2017
b3b69d1
Merge branch 'mm/users_controller_tests_and_methods'
Oct 19, 2017
9c1eb43
Merge branch 'master' of https://github.com/canaanwest/betsy
Oct 19, 2017
12b2a01
removing producT controller (singular)
canaanwest Oct 19, 2017
d984b07
Merge branch 'master' of https://github.com/canaanwest/betsy
canaanwest Oct 19, 2017
200344e
added an additional model user model test
Oct 19, 2017
c64ed30
Merge branch 'master' of https://github.com/canaanwest/betsy
Oct 19, 2017
57f7ba3
complete user controller methods and tests
Oct 19, 2017
717df4e
added and additional test to the users controller
Oct 19, 2017
51c6024
completed basic model testing
Oct 19, 2017
402c219
minor changes
Oct 19, 2017
f35e62e
completed item model tests
Oct 19, 2017
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
Prev Previous commit
Next Next commit
Fixing seed data formatting
  • Loading branch information
canaanwest committed Oct 19, 2017
commit 3b150571f0f8dff8b2c4ef914470f303ce8972d4
1 change: 1 addition & 0 deletions app/controllers/product_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ def index
end

def show
@product = Product.find(params[:id].to_i)
end

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

<section class="products">

<% @products.each do |product| %>
<article class="product_details">
<ul>
<li>
<%= product.name %>
<%= product.price %>
<%= product.description %>
<%= product.user %>
</li>
</ul>
<% end %>
</article>


</section>
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
resources :orders

resources :billing_data
resources :product
resources :products


# get 'items/index'
Expand Down
3 changes: 2 additions & 1 deletion db/billing_data_seeds.csv
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
billing_data_id,user_id,username,email,mailing_address,credit_card_name,credit_card_number,credit_card_CVV,billing_zip_code1,2, sage_elliot,selliot@gmail.com,"123 Yesler Way, Seattle, WA",Sage Elliot,7777 5555 4444 2222,444,98101
billing_data_id,user_id,username,email,mailing_address,credit_card_name,credit_card_number,credit_card_CVV,billing_zip_code
1,2, sage_elliot,selliot@gmail.com,"123 Yesler Way, Seattle, WA",Sage Elliot,7777 5555 4444 2222,444,98101
9 changes: 8 additions & 1 deletion db/category_seeds.csv
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
category_id,category1,clothing2,tour3,class4,collectible5,cabin gear6,music7,dog gear
category_id,category
1,clothing,
2,tour,
3,class,
4,collectible,
5,cabin gear,
6,music,
7,dog gear
Expand Down
50 changes: 49 additions & 1 deletion db/items_seeds.csv
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
item_id,product_id,purchase_status,shipping_status1,1,FALSE,FALSE2,1,FALSE,FALSE3,1,FALSE,FALSE4,1,FALSE,FALSE5,1,FALSE,FALSE6,2,FALSE,FALSE7,2,FALSE,FALSE8,2,FALSE,FALSE9,2,FALSE,FALSE10,2,FALSE,FALSE11,2,FALSE,FALSE12,2,FALSE,FALSE13,2,FALSE,FALSE14,2,FALSE,FALSE15,3,FALSE,FALSE16,3,FALSE,FALSE17,3,FALSE,FALSE18,3,FALSE,FALSE19,3,FALSE,FALSE20,3,FALSE,FALSE21,4,FALSE,FALSE22,4,FALSE,FALSE23,4,FALSE,FALSE24,4,FALSE,FALSE25,5,FALSE,FALSE26,5,FALSE,FALSE27,5,FALSE,FALSE28,5,FALSE,FALSE29,6,FALSE,FALSE30,6,FALSE,FALSE31,7,FALSE,FALSE32,7,FALSE,FALSE33,7,FALSE,FALSE34,7,FALSE,FALSE35,8,FALSE,FALSE36,8,FALSE,FALSE37,9,TRUE,FALSE38,10,FALSE,FALSE39,10,FALSE,FALSE40,10,FALSE,FALSE41,10,FALSE,FALSE42,10,FALSE,FALSE43,10,FALSE,FALSE44,10,FALSE,FALSE45,10,FALSE,FALSE46,10,FALSE,FALSE47,10,FALSE,FALSE48,10,FALSE,FALSE
item_id,product_id,purchase_status,shipping_status
1,1,FALSE,FALSE,
2,1,FALSE,FALSE,
3,1,FALSE,FALSE,
4,1,FALSE,FALSE,
5,1,FALSE,FALSE,
6,2,FALSE,FALSE,
7,2,FALSE,FALSE,
8,2,FALSE,FALSE,
9,2,FALSE,FALSE,
10,2,FALSE,FALSE,
11,2,FALSE,FALSE,
12,2,FALSE,FALSE,
13,2,FALSE,FALSE,
14,2,FALSE,FALSE,
15,3,FALSE,FALSE,
16,3,FALSE,FALSE,
17,3,FALSE,FALSE,
18,3,FALSE,FALSE,
19,3,FALSE,FALSE,
20,3,FALSE,FALSE,
21,4,FALSE,FALSE,
22,4,FALSE,FALSE,
23,4,FALSE,FALSE,
24,4,FALSE,FALSE,
25,5,FALSE,FALSE,
26,5,FALSE,FALSE,
27,5,FALSE,FALSE,
28,5,FALSE,FALSE,
29,6,FALSE,FALSE,
30,6,FALSE,FALSE,
31,7,FALSE,FALSE,
32,7,FALSE,FALSE,
33,7,FALSE,FALSE,
34,7,FALSE,FALSE,
35,8,FALSE,FALSE,
36,8,FALSE,FALSE,
37,9,TRUE,FALSE,
38,10,FALSE,FALSE,
39,10,FALSE,FALSE,
40,10,FALSE,FALSE,
41,10,FALSE,FALSE,
42,10,FALSE,FALSE,
43,10,FALSE,FALSE,
44,10,FALSE,FALSE,
45,10,FALSE,FALSE,
46,10,FALSE,FALSE,
47,10,FALSE,FALSE,
48,10,FALSE,FALSE
Expand Down
10 changes: 9 additions & 1 deletion db/order_products_seeds.csv
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
order_product_id,order_id,product_id,quantity1,1,1,42,1,2,53,1,3,14,2,4,35,2,5,26,2,6,27,2,7,18,3,9,1
order_product_id,order_id,product_id,quantity
1,1,1,4,
2,1,2,5,
3,1,3,1,
4,2,4,3,
5,2,5,2,
6,2,6,2,
7,2,7,1,
8,3,9,1
5 changes: 4 additions & 1 deletion db/order_seeds.csv
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
order_id,session_id,user_id,order_status,billing_data_id1,89,5,pending,2,322,,pending,3,867,2,paid,1
order_id,session_id,user_id,order_status,billing_data_id
1,89,5,pending,2,
2,32,2,pending,3,
3,867,2,paid,1,
Expand Down
12 changes: 11 additions & 1 deletion db/product_seeds.csv
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
product_id,category_id,user_id,name,price,description1,6,1,Mack Daddy,12.99,"Mack Daddy is the third album by Sir Mix-a-Lot, and his first album with a Parental Advisory label. It was released on February 4, 1992, on Def American Recordings. The album is particularly notable for the hit single ""Baby Got Back."""2,6,1,Nevermind,9.95,"Nevermind is the second studio album by American grunge rock band Nirvana, released on September 24, 1991 by DGC Records. Produced by Butch Vig, Nevermind was the band's first release on DGC. It was also their first album to feature drummer Dave Grohl."3,1,2,Red Plaid Shirt- Size S,49.95,"Classic lumberjack shirt that you wear to the bar, of course."4,1,2,Red Plaid Shirt- Size M,49.95,"Classic lumberjack shirt that you wear to the bar, of course."5,1,2,Red Plaid Shirt- Size L,49.95,"Classic lumberjack shirt that you wear to the bar, of course."6,4,7,Framed Bigfoot Sighting Photo,119.5,Proof that Sasquatch is real.7,4,10,Sasquatch Action Figure,14.99,Plastic figurine8,7,8,Red Plaid Dog Bandana,5.25,Every PNW dog needs one of these!9,6,4,Crash,8.5,"Crash is the second studio album by American rock group Dave Matthews Band, released on April 30, 1996. By March 16, 2000, the album had sold seven million copies, and was certified 7_ platinum by the RIAA.[1] This is currently Dave Matthews Band's best-selling album."10,6,4,Live at Red Rocks,15,"Live at Red Rocks 8.15.95 is an album by the Dave Matthews Band, released on October 28, 1997. It was recorded live at Red Rocks Amphitheatre in Morrison, Colorado on August 15, 1995. "
product_id,category_id,user_id,name,price,description
1,6,1,Mack Daddy,12.99,"Mack Daddy is the third album by Sir Mix-a-Lot, and his first album with a Parental Advisory label. It was released on February 4, 1992, on Def American Recordings. The album is particularly notable for the hit single ""Baby Got Back.",
2,6,1,Nevermind,9.95,"Nevermind is the second studio album by American grunge rock band Nirvana, released on September 24, 1991 by DGC Records. Produced by Butch Vig, Nevermind was the band's first release on DGC. It was also their first album to feature drummer Dave Grohl.",
3,1,2,Red Plaid Shirt- Size S,49.95,"Classic lumberjack shirt that you wear to the bar, of course.",
4,1,2,Red Plaid Shirt- Size M,49.95,"Classic lumberjack shirt that you wear to the bar, of course.",
5,1,2,Red Plaid Shirt- Size L,49.95,"Classic lumberjack shirt that you wear to the bar, of course.",
6,4,7,Framed Bigfoot Sighting Photo,119.5,"Proof that Sasquatch is real.",
7,4,10,Sasquatch Action Figure,14.99,"Plastic figurine",
8,7,8,Red Plaid Dog Bandana,5.25,"Every PNW dog needs one of these!",
9,6,4,Crash,8.5,"Crash is the second studio album by American rock group Dave Matthews Band, released on April 30, 1996. By March 16, 2000, the album had sold seven million copies, and was certified 7_ platinum by the RIAA.[1] This is currently Dave Matthews Band's best-selling album.",
10,6,4,Live at Red Rocks,15,"Live at Red Rocks 8.15.95 is an album by the Dave Matthews Band, released on October 28, 1997. It was recorded live at Red Rocks Amphitheatre in Morrison, Colorado on August 15, 1995."
Expand Down
8 changes: 7 additions & 1 deletion db/reviews_seeds.csv
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
review_id,user_id,product_id,text,rating1,1,7,Great to use to make fake bigfoot photos throughout the PNW. It lives on my dashboard!,52,1,5,Fits perfect but wish it had elbow patches.,43,3,7,My daughter broke it within 5 seconds of opening it. Cheap plastic!,14,5,6,Awesome conversation piece.,55,7,10,DMB forever! I see him at the Wallingford QFC all the time.,56,8,8,Fell off my dog all the time because there isn't enough velcro on the clasp. But very cute.,2
review_id,user_id,product_id,text,rating
1,1,7,Great to use to make fake bigfoot photos throughout the PNW. It lives on my dashboard!,5,
2,1,5,Fits perfect but wish it had elbow patches.,4,
3,3,7,My daughter broke it within 5 seconds of opening it. Cheap plastic!,1,
4,5,6,Awesome conversation piece.,5,
5,7,10,DMB forever! I see him at the Wallingford QFC all the time.,5,
6,8,8,Fell off my dog all the time because there isn't enough velcro on the clasp. But very cute.,2
Expand Down
102 changes: 51 additions & 51 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
# # This file should contain all the record creation needed to seed the database with its default values.
# # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
# #
# # Examples:
# #
# # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# # Character.create(name: 'Luke', movie: movies.first)
#
# # This file should contain all the record creation needed to seed the database with its default values.
# # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
# #
# # Examples:
# #
# # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# # Character.create(name: 'Luke', movie: movies.first)
#
# require 'csv'
#
# PRODUCT_FILE = Rails.root.join('db', 'seed_data', 'product_seeds.csv')
# puts "Loading raw work data from #{PRODUCT_FILE}"
#
# product_failures = []
# CSV.foreach(PRODUCT_FILE, :headers => true) do |row|
# product = Product.new
# product.id = row['product_id']
# product.category_id = row['category_id']
# product.user_id = row['user_id']
# product.name = row['name']
# product.price = row['price']
# product.description = row['description']
# puts "Created product: #{product.inspect}"
# successful = product.save
# if !successful
# product_failures << product
# end
# end
#
# puts "Added #{Product.count} product records"
# puts "#{product_failures.length} product failed to save"
#
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)

# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)

require 'csv'

PRODUCT_FILE = Rails.root.join('db', 'seed_data', 'product_seeds.csv')
puts "Loading raw work data from #{PRODUCT_FILE}"

product_failures = []
CSV.foreach(PRODUCT_FILE, :headers => true) do |row|
product = Product.new
product.id = row['product_id']
product.category_id = row['category_id']
product.user_id = row['user_id']
product.name = row['name']
product.price = row['price']
product.description = row['description']
puts "Created product: #{product.inspect}"
successful = product.save
if !successful
product_failures << product
end
end

puts "Added #{Product.count} product records"
puts "#{product_failures.length} product failed to save"

#
#
# USER_FILE = Rails.root.join('db', 'seed_data', 'user_seeds.csv')
Expand Down Expand Up @@ -196,14 +196,14 @@
# puts "Added #{Item.count} item records"
# puts "#{item_failures.length} item records failed to save"
#
#
# # Since we set the primary key (the ID) manually on each of the
# # tables, we've got to tell postgres to reload the latest ID
# # values. Otherwise when we create a new record it will try
# # to start at ID 1, which will be a conflict.
# puts "Manually resetting PK sequence on each table"
# ActiveRecord::Base.connection.tables.each do |t|
# ActiveRecord::Base.connection.reset_pk_sequence!(t)
# end
#
# puts "done"

# Since we set the primary key (the ID) manually on each of the
# tables, we've got to tell postgres to reload the latest ID
# values. Otherwise when we create a new record it will try
# to start at ID 1, which will be a conflict.
puts "Manually resetting PK sequence on each table"
ActiveRecord::Base.connection.tables.each do |t|
ActiveRecord::Base.connection.reset_pk_sequence!(t)
end

puts "done"
12 changes: 11 additions & 1 deletion db/user_seeds.csv
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
user_id,username,email1,sir_mixalot,mixalot@google.com2, sage_elliot,selliot@gmail.com3,jhendrix,hendrix@outlook.com4,dmatthews,dmatthews@google.com5,quincy-jones,qjones@yahoo.com6,KennyG,Kgorelick@hotmail.com7,Jane Pine,janep@gmail.com8,Jack Union,jacku@yahoo.com9,Trey Smith,SmithT@gmail.com10,Amelia Yesler,amelia@hotmail.com
user_id,username,email
1,sir_mixalot,mixalot@google.com,
2,sage_elliot,selliot@gmail.com,
3,jhendrix,hendrix@outlook.com,
4,dmatthews,dmatthews@google.com,
5,quincy-jones,qjones@yahoo.com,
6,KennyG,Kgorelick@hotmail.com,
7,Jane Pine,janep@gmail.com,
8,Jack Union,jacku@yahoo.com,
9,Trey Smith,SmithT@gmail.com,
10,Amelia Yesler,amelia@hotmail.com
Expand Down