Skip to content

Commit efc9f16

Browse files
committed
Added Badge Counters for Orders and Basket Items
1 parent ac362c1 commit efc9f16

4 files changed

Lines changed: 21 additions & 17 deletions

File tree

app/controllers/line_items_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def create
2525
# Save and redirect to cart show path
2626
@line_item.save!
2727

28-
redirect_to cart_path(current_cart)
28+
# redirect_to cart_path(@current_cart)
29+
redirect_back(fallback_location: root_url)
2930
end
3031

3132
def destroy

app/controllers/sessions_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def create
1111
if user.activated?
1212
log_in user
1313
params[:session][:remember_me] == '1' ? remember(user) : forget(user)
14-
redirect_back_or user
14+
# redirect_back_or user
15+
redirect_back_or root_url
1516
else
1617
message = 'Account not activated. '
1718
message += 'Check your email for the activation link.'

app/views/layouts/_header.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
<li><%= link_to "#", { :class => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'data-placement' => 'top', :title => 'Account', 'data-original-title' => 'Account' } do %>
2727
<!-- <i class="glyphicon glyphicon-user"></i> -->
2828
<i class="glyphicon glyphicon-shopping-cart" style="color:#FFD700"></i>
29-
Basket |
29+
Basket <span class="badge badge-pill badge-warning"><%= @current_cart.line_items.count %></span> |
3030
<i class="glyphicon glyphicon-eye-open" style="color:firebrick"></i>
31-
Orders
31+
Orders <span class="badge badge-pill badge-warning"><%= @current_user.orders.count %></span>
3232
<b class="caret"></b>
3333
<% end %>
3434

app/views/static_pages/home.html.erb

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@
1717
</div>
1818
<%end %>
1919
<%# else %><% end %>
20-
<div class="center jumbotron">
21-
<h2>
22-
<%= link_to image_tag("logo.jpg",size:"52x42" , alt: "Shop logo"), 'http://rubyonrails.org/' %>
23-
Welcome to dopeshop!
20+
<% if !logged_in? %>
21+
<div class="center jumbotron">
22+
<h2>
23+
<%= link_to image_tag("logo.jpg",size:"52x42" , alt: "Shop logo"), 'http://rubyonrails.org/' %>
24+
Welcome to dopeshop!
2425

25-
</h2>
26+
</h2>
2627

27-
<% if !logged_in? %>
28-
<%= link_to "Log in", login_path, class: "btn btn-lg btn-success" %>
29-
<strong >
30-
or
31-
</strong>
32-
<%= link_to "Sign up", signup_path, class: "btn btn-lg btn-primary" %>
33-
<% end %>
34-
</div>
28+
<% if !logged_in? %>
29+
<%= link_to "Log in", login_path, class: "btn btn-lg btn-success" %>
30+
<strong >
31+
or
32+
</strong>
33+
<%= link_to "Sign up", signup_path, class: "btn btn-lg btn-primary" %>
34+
<% end %>
35+
</div>
36+
<%end %>
3537

3638
<%= render 'shared/products' %>
3739
<%# end %>

0 commit comments

Comments
 (0)