Skip to content

Commit e85c574

Browse files
committed
cleaned up product loop, updated cart controller
1 parent b7c6261 commit e85c574

8 files changed

Lines changed: 28 additions & 11 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ gem 'binding_of_caller'
3838
gem 'jquery-rails'
3939
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'
4040
gem 'figaro'
41+
gem 'faker', '~> 2.1', '>= 2.1.2'
4142
# Use ActiveStorage variant
4243
# gem 'mini_magick', '~> 4.8'
4344

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ GEM
110110
warden (~> 1.2.3)
111111
erubi (1.8.0)
112112
execjs (2.7.0)
113+
faker (2.1.2)
114+
i18n (>= 0.8)
113115
faraday (0.15.4)
114116
multipart-post (>= 1.2, < 3)
115117
ffi (1.11.1)
@@ -267,6 +269,7 @@ DEPENDENCIES
267269
chromedriver-helper
268270
coffee-rails (~> 4.2)
269271
devise
272+
faker (~> 2.1, >= 2.1.2)
270273
figaro
271274
font-awesome-rails
272275
hirb (~> 0.7.3)

app/controllers/cart_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ def order_complete
1010
)
1111

1212
charge = Stripe::Charge.create(
13-
:customer => customer.id
14-
:amount => @amount
15-
:description => 'Rails Stripe customer'
13+
:customer => customer.id,
14+
:amount => @amount,
15+
:description => 'Rails Stripe customer',
1616
:currency => 'usd'
1717
)
1818

app/models/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class User < ApplicationRecord
22
# Include default devise modules. Others available are:
33
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
4-
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :trackable
4+
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable #:trackable
55

66
has_many :orders
77

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h2>Thank you for your order!</h2>
2+
<p>Order #<%= @order.id %> will be shipping to you, <%= @order.user.name %>, as soon as possible!</p>

app/views/partials/_product_loop.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<% else %>
88
<p>no image</p>
99
<% end %>
10-
<h3><%= link_to product.name, product %></h3>
10+
<h3><%= link_to product.name.truncate(25), product %></h3>
1111
<p><%= number_to_currency product.price %></p>
1212
<p>
1313
<a href="#" data-toggle="modal" data-target="#myModal_<%= product.id %>"><span class="glyphicon glyphicon-plus"></span>More Info</a>

db/migrate/20190813154104_devise_create_users.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def change
1515
t.datetime :remember_created_at
1616

1717
## Trackable
18-
# t.integer :sign_in_count, default: 0, null: false
19-
# t.datetime :current_sign_in_at
20-
# t.datetime :last_sign_in_at
21-
# t.string :current_sign_in_ip
22-
# t.string :last_sign_in_ip
18+
t.integer :sign_in_count, default: 0, null: false
19+
t.datetime :current_sign_in_at
20+
t.datetime :last_sign_in_at
21+
t.string :current_sign_in_ip
22+
t.string :last_sign_in_ip
2323

2424
## Confirmable
2525
# t.string :confirmation_token

db/seeds.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,15 @@
66
{name: "Video Games"},
77
{name: "Appliances"},
88
{name: "other"},
9-
])
9+
]),
10+
50.times do
11+
Product.create!(
12+
name: Faker::Commerce.product_name,
13+
price: Faker::Commerce.price,
14+
quantity: rand(100),
15+
description: Faker::Lorem.sentences.to_s,
16+
brand: Faker::Appliance.brand,
17+
rating: rand(10),
18+
category_id: rand(1..7)
19+
)
20+
end

0 commit comments

Comments
 (0)