diff --git a/.gitignore b/.gitignore
index 9f14c9f5b6..095fa64412 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,4 @@
# Ignore Byebug command history file.
.byebug_history
config/database.yml
+public/uploads
diff --git a/Gemfile b/Gemfile
index 0447f70941..915cf84a61 100644
--- a/Gemfile
+++ b/Gemfile
@@ -30,9 +30,12 @@ gem 'jbuilder', '~> 2.5'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
+gem 'bootstrap-sass'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
+ gem 'pry'
+ gem 'awesome_rails_console'
end
group :development do
@@ -46,3 +49,8 @@ end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
+gem 'devise'
+gem 'simple_form'
+gem 'font-awesome-rails'
+gem 'carrierwave'
+gem 'mini_magick'
diff --git a/Gemfile.lock b/Gemfile.lock
index 96abec2521..1e2b433367 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -39,8 +39,24 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.1)
+ autoprefixer-rails (6.7.7.2)
+ execjs
+ awesome_print (1.8.0)
+ awesome_rails_console (0.4.0)
+ awesome_print
+ pry-rails
+ railties
+ bcrypt (3.1.11)
+ bootstrap-sass (3.3.7)
+ autoprefixer-rails (>= 5.2.1)
+ sass (>= 3.3.4)
builder (3.2.2)
byebug (9.0.5)
+ carrierwave (1.2.1)
+ activemodel (>= 4.0.0)
+ activesupport (>= 4.0.0)
+ mime-types (>= 1.16)
+ coderay (1.1.2)
coffee-rails (4.2.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.2.x)
@@ -50,9 +66,17 @@ GEM
coffee-script-source (1.10.0)
concurrent-ruby (1.0.2)
debug_inspector (0.0.2)
+ devise (4.2.1)
+ bcrypt (~> 3.0)
+ orm_adapter (~> 0.1)
+ railties (>= 4.1.0, < 5.1)
+ responders
+ warden (~> 1.2.3)
erubis (2.7.0)
execjs (2.7.0)
ffi (1.9.14)
+ font-awesome-rails (4.7.0.2)
+ railties (>= 3.2, < 5.2)
globalid (0.3.7)
activesupport (>= 4.1.0)
i18n (0.7.0)
@@ -74,6 +98,7 @@ GEM
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
+ mini_magick (4.8.0)
mini_portile2 (2.1.0)
minitest (5.9.0)
multi_json (1.12.1)
@@ -81,7 +106,13 @@ GEM
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
+ orm_adapter (0.5.0)
pkg-config (1.1.7)
+ pry (0.11.0)
+ coderay (~> 1.1.0)
+ method_source (~> 0.8.1)
+ pry-rails (0.3.6)
+ pry (>= 0.10.4)
puma (3.6.0)
rack (2.0.1)
rack-test (0.6.3)
@@ -113,6 +144,8 @@ GEM
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
+ responders (2.3.0)
+ railties (>= 4.2.0, < 5.1)
sass (3.4.22)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
@@ -120,6 +153,9 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
+ simple_form (3.4.0)
+ actionpack (> 4, < 5.1)
+ activemodel (> 4, < 5.1)
spring (1.7.2)
spring-watcher-listen (2.0.0)
listen (>= 2.7, < 4.0)
@@ -142,6 +178,8 @@ GEM
thread_safe (~> 0.1)
uglifier (3.0.1)
execjs (>= 0.3.0, < 3)
+ warden (1.2.7)
+ rack (>= 1.0)
web-console (3.3.1)
actionview (>= 5.0)
activemodel (>= 5.0)
@@ -155,14 +193,22 @@ PLATFORMS
ruby
DEPENDENCIES
+ awesome_rails_console
+ bootstrap-sass
byebug
+ carrierwave
coffee-rails (~> 4.2)
+ devise
+ font-awesome-rails
jbuilder (~> 2.5)
jquery-rails
listen (~> 3.0.5)
+ mini_magick
+ pry
puma (~> 3.0)
rails (~> 5.0.0)
sass-rails (~> 5.0)
+ simple_form
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
@@ -172,4 +218,4 @@ DEPENDENCIES
web-console
BUNDLED WITH
- 1.12.5
+ 1.14.5
diff --git a/app/assets/javascripts/admin/products.coffee b/app/assets/javascripts/admin/products.coffee
new file mode 100644
index 0000000000..24f83d18bb
--- /dev/null
+++ b/app/assets/javascripts/admin/products.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index b12018d099..ceee63822c 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -13,4 +13,6 @@
//= require jquery
//= require jquery_ujs
//= require turbolinks
+//= require bootstrap/alert
+//= require bootstrap/dropdown
//= require_tree .
diff --git a/app/assets/javascripts/cart_items.coffee b/app/assets/javascripts/cart_items.coffee
new file mode 100644
index 0000000000..24f83d18bb
--- /dev/null
+++ b/app/assets/javascripts/cart_items.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/carts.coffee b/app/assets/javascripts/carts.coffee
new file mode 100644
index 0000000000..24f83d18bb
--- /dev/null
+++ b/app/assets/javascripts/carts.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/products.coffee b/app/assets/javascripts/products.coffee
new file mode 100644
index 0000000000..24f83d18bb
--- /dev/null
+++ b/app/assets/javascripts/products.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/welcome.coffee b/app/assets/javascripts/welcome.coffee
new file mode 100644
index 0000000000..24f83d18bb
--- /dev/null
+++ b/app/assets/javascripts/welcome.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/stylesheets/admin/products.scss b/app/assets/stylesheets/admin/products.scss
new file mode 100644
index 0000000000..06dc60c289
--- /dev/null
+++ b/app/assets/stylesheets/admin/products.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the admin/products controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.scss
similarity index 90%
rename from app/assets/stylesheets/application.css
rename to app/assets/stylesheets/application.scss
index 0ebd7fe829..71c437ef79 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.scss
@@ -13,3 +13,7 @@
*= require_tree .
*= require_self
*/
+
+@import "bootstrap-sprockets";
+@import "bootstrap";
+@import "font-awesome";
diff --git a/app/assets/stylesheets/cart_items.scss b/app/assets/stylesheets/cart_items.scss
new file mode 100644
index 0000000000..c8ba3800bd
--- /dev/null
+++ b/app/assets/stylesheets/cart_items.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the cart_items controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/carts.scss b/app/assets/stylesheets/carts.scss
new file mode 100644
index 0000000000..62647c9dde
--- /dev/null
+++ b/app/assets/stylesheets/carts.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the carts controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/products.scss b/app/assets/stylesheets/products.scss
new file mode 100644
index 0000000000..89e2e8db07
--- /dev/null
+++ b/app/assets/stylesheets/products.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the products controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/welcome.scss b/app/assets/stylesheets/welcome.scss
new file mode 100644
index 0000000000..77ce11a740
--- /dev/null
+++ b/app/assets/stylesheets/welcome.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the welcome controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/admin/products_controller.rb b/app/controllers/admin/products_controller.rb
new file mode 100644
index 0000000000..ce725a7b6f
--- /dev/null
+++ b/app/controllers/admin/products_controller.rb
@@ -0,0 +1,43 @@
+class Admin::ProductsController < ApplicationController
+ before_action :authenticate_user!
+ before_action :admin_required
+ layout "admin"
+
+ def index
+ @products = Product.all
+ end
+
+ def new
+ @product = Product.new
+ end
+
+ def edit
+ @product = Product.new
+ end
+
+ def update
+ @product = Product.find(params[:id])
+ if @product.update(product_params)
+ redirect_to admin_products_path
+ else
+ render :edit
+ end
+ end
+
+ def create
+ @product = Product.new(product_params)
+
+ if @product.save
+ redirect_to admin_products_path
+ else
+ render :new
+ end
+ end
+
+ private
+
+ def product_params
+ params.require(:product).permit(:title, :description, :quantity, :price, :image)
+ end
+
+end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 1c07694e9d..28a21bc232 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,3 +1,26 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
+
+ def admin_required
+ if !current_user.admin?
+ redirect_to "/", alert:" You are not admin "
+ end
+ end
+
+ helper_method :current_cart
+
+ def current_cart
+ @current_cart ||= find_cart
+ end
+
+ private
+
+ def find_cart
+ cart = Cart.find_by(id: session[:cart_id])
+ if cart.blank?
+ cart = Cart.create
+ end
+ session[ :cart_id] = cart.id
+ return cart
+ end
end
diff --git a/app/controllers/cart_items_controller.rb b/app/controllers/cart_items_controller.rb
new file mode 100644
index 0000000000..554868857b
--- /dev/null
+++ b/app/controllers/cart_items_controller.rb
@@ -0,0 +1,29 @@
+class CartItemsController < ApplicationController
+ before_action :authenticate_user!
+
+ def destroy
+ @cart = current_cart
+ @cart_item = @cart.cart_items.find_by(product_id: params[:id])
+ @product = @cart_item.product
+ @cart_item.destroy
+
+ flash[:warning] = "成功将 #{@product.title} 从购物车删除"
+ redirect_to :back
+ end
+
+ def update
+ @cart = current_cart
+ @cart_item = @cart.cart_items.find_by(product_id: params[:id])
+ if @cart_item.product.quantity >= cart_item_params[:quantity].to_i
+ @cart_item.update(cart_item_params)
+ flash[:notice] = "成功变更数量"
+ else
+ flash[:warning] = "数量不足以加入购物车"
+ end
+ redirect_to carts_path
+ end
+
+ def cart_item_params
+ params.require(:cart_item).permit(:quantity)
+ end
+end
diff --git a/app/controllers/carts_controller.rb b/app/controllers/carts_controller.rb
new file mode 100644
index 0000000000..51879b381e
--- /dev/null
+++ b/app/controllers/carts_controller.rb
@@ -0,0 +1,7 @@
+class CartsController < ApplicationController
+ def clean
+ current_cart.clean!
+ flash[:warning] = "已清空购物车"
+ redirect_to carts_path
+ end
+end
diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb
new file mode 100644
index 0000000000..bfe87b2e52
--- /dev/null
+++ b/app/controllers/products_controller.rb
@@ -0,0 +1,20 @@
+class ProductsController < ApplicationController
+ def index
+ @products = Product.all
+ end
+
+ def show
+ @product = Product.find(params[:id])
+ end
+
+ def add_to_cart
+ @product = Product.find(params[:id])
+ if !current_cart.products.include? (@product)
+ current_cart.add_product_to_cart(@product)
+ flash[:notice] = "成功将#{@product.title} 加入购物车"
+ else
+ flash[:warning] = "你的购物车内已有此物品"
+ end
+ redirect_to :back
+ end
+end
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb
new file mode 100644
index 0000000000..3b6e7e7cfc
--- /dev/null
+++ b/app/controllers/welcome_controller.rb
@@ -0,0 +1,5 @@
+class WelcomeController < ApplicationController
+ def index
+ flash[:notice] = "Goodbye Loser"
+ end
+end
diff --git a/app/helpers/admin/products_helper.rb b/app/helpers/admin/products_helper.rb
new file mode 100644
index 0000000000..977a242f66
--- /dev/null
+++ b/app/helpers/admin/products_helper.rb
@@ -0,0 +1,2 @@
+module Admin::ProductsHelper
+end
diff --git a/app/helpers/cart_items_helper.rb b/app/helpers/cart_items_helper.rb
new file mode 100644
index 0000000000..f30f6834fd
--- /dev/null
+++ b/app/helpers/cart_items_helper.rb
@@ -0,0 +1,2 @@
+module CartItemsHelper
+end
diff --git a/app/helpers/carts_helper.rb b/app/helpers/carts_helper.rb
new file mode 100644
index 0000000000..e307f24fa7
--- /dev/null
+++ b/app/helpers/carts_helper.rb
@@ -0,0 +1,5 @@
+module CartsHelper
+ def render_cart_total_price(cart)
+ cart.total_price
+ end
+end
diff --git a/app/helpers/flashes_helper.rb b/app/helpers/flashes_helper.rb
new file mode 100644
index 0000000000..c451f21d8e
--- /dev/null
+++ b/app/helpers/flashes_helper.rb
@@ -0,0 +1,11 @@
+module FlashesHelper
+ FLASH_CLASSES = { alert: "danger", notice: "success", warning: "warning"}.freeze
+
+ def flash_class(key)
+ FLASH_CLASSES.fetch key.to_sym, key
+ end
+
+ def user_facing_flashes
+ flash.to_hash.slice "alert", "notice","warning"
+ end
+end
diff --git a/app/helpers/products_helper.rb b/app/helpers/products_helper.rb
new file mode 100644
index 0000000000..ab5c42b325
--- /dev/null
+++ b/app/helpers/products_helper.rb
@@ -0,0 +1,2 @@
+module ProductsHelper
+end
diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb
new file mode 100644
index 0000000000..eeead45fc9
--- /dev/null
+++ b/app/helpers/welcome_helper.rb
@@ -0,0 +1,2 @@
+module WelcomeHelper
+end
diff --git a/app/models/cart.rb b/app/models/cart.rb
new file mode 100644
index 0000000000..803293f153
--- /dev/null
+++ b/app/models/cart.rb
@@ -0,0 +1,25 @@
+class Cart < ApplicationRecord
+ has_many :cart_items
+ has_many :products, through: :cart_items, source: :product
+
+ def add_product_to_cart(product)
+ ci = cart_items.build
+ ci.product = product
+ ci.quantity = 1
+ ci.save
+ end
+
+ def total_price
+ sum = 0
+ cart_items.each do |cart_item|
+ if cart_item.product.price.present?
+ sum += cart_item.product.price * cart_item.quantity
+ end
+ end
+ sum
+end
+
+ def clean!
+ cart_items.destroy_all
+ end
+end
diff --git a/app/models/cart_item.rb b/app/models/cart_item.rb
new file mode 100644
index 0000000000..23b07149b0
--- /dev/null
+++ b/app/models/cart_item.rb
@@ -0,0 +1,4 @@
+class CartItem < ApplicationRecord
+ belongs_to :cart
+ belongs_to :product
+end
diff --git a/app/models/product.rb b/app/models/product.rb
new file mode 100644
index 0000000000..266f69c35d
--- /dev/null
+++ b/app/models/product.rb
@@ -0,0 +1,3 @@
+class Product < ApplicationRecord
+ mount_uploader :image,ImageUploader
+end
diff --git a/app/models/user.rb b/app/models/user.rb
new file mode 100644
index 0000000000..bcc827cc1e
--- /dev/null
+++ b/app/models/user.rb
@@ -0,0 +1,11 @@
+class User < ApplicationRecord
+ # Include default devise modules. Others available are:
+ # :confirmable, :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable, :registerable,
+ :recoverable, :rememberable, :trackable, :validatable
+
+ def admin?
+ is_admin
+ end
+
+end
diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb
new file mode 100644
index 0000000000..6b5b807776
--- /dev/null
+++ b/app/uploaders/image_uploader.rb
@@ -0,0 +1,59 @@
+class ImageUploader < CarrierWave::Uploader::Base
+
+ # Include RMagick or MiniMagick support:
+ # include CarrierWave::RMagick
+ include CarrierWave::MiniMagick
+
+ # Choose what kind of storage to use for this uploader:
+ storage :file
+ # storage :fog
+
+ # Override the directory where uploaded files will be stored.
+ # This is a sensible default for uploaders that are meant to be mounted:
+ def store_dir
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
+ end
+
+ process resize_to_fit: [800,800]
+
+ version :thumb do
+ process resize_to_fill: [200,200]
+ end
+
+ version :medium do
+ process resize_to_fill: [400,400]
+ end
+
+ # Provide a default URL as a default if there hasn't been a file uploaded:
+ # def default_url(*args)
+ # # For Rails 3.1+ asset pipeline compatibility:
+ # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
+ #
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
+ # end
+
+ # Process files as they are uploaded:
+ # process scale: [200, 300]
+ #
+ # def scale(width, height)
+ # # do something
+ # end
+
+ # Create different versions of your uploaded files:
+ # version :thumb do
+ # process resize_to_fit: [50, 50]
+ # end
+
+ # Add a white list of extensions which are allowed to be uploaded.
+ # For images you might use something like this:
+ # def extension_whitelist
+ # %w(jpg jpeg gif png)
+ # end
+
+ # Override the filename of the uploaded files:
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
+ # def filename
+ # "something.jpg" if original_filename
+ # end
+
+end
diff --git a/app/views/admin/products/edit.html.erb b/app/views/admin/products/edit.html.erb
new file mode 100644
index 0000000000..42d13c5211
--- /dev/null
+++ b/app/views/admin/products/edit.html.erb
@@ -0,0 +1,32 @@
+
Edit Product
+
+<%= simple_form_for [:admin, @product] do |f| %>
+
+
+ <%= f.input :title %>
+
+
+
+ <%= f.input :description %>
+
+
+
+ <%= f.input :quantity %>
+
+
+
+ <%= f.input :price %>
+
+
+ <% if @product.image.present? %>
+ 目前商品图
+ <%= image_tag(@product.image.thumb.url) %>
+ <% end %>
+
+
+ <%= f.input :image, as: :file %>
+
+
+ <%= f.submit "Submit", data: { disable_with: "Submitting..." } %>
+
+<% end %>
diff --git a/app/views/admin/products/index.html.erb b/app/views/admin/products/index.html.erb
new file mode 100644
index 0000000000..366e601891
--- /dev/null
+++ b/app/views/admin/products/index.html.erb
@@ -0,0 +1,43 @@
+ Product List
+
+ <%= link_to("新增产品", new_admin_product_path, class:"btn btn-primary btn-sm")%>
+
+
+
+
+
+ # |
+ Product Pic |
+ Name |
+ Price |
+ Options |
+
+
+
+ <% @products.each do |product| %>
+
+
+ <%= product.id %>
+ |
+
+ <%= link_to product_path(product) do %>
+ <% if product.image.present? %>
+ <%= image_tag(product.image.thumb.url, class: "thumbnail") %>
+ <% else %>
+ <%= image_tag("http://placehold.it/200x200&text=No Pic", class: "thumbnail") %>
+ <% end %>
+ <% end %>
+ |
+
+ <%= product.title %>
+ |
+
+ <%= product.price %>
+ |
+
+ <%= link_to("Edit", edit_admin_product_path(product)) %>
+ |
+
+ <% end %>
+
+
diff --git a/app/views/admin/products/new.html.erb b/app/views/admin/products/new.html.erb
new file mode 100644
index 0000000000..d4ed8d1a89
--- /dev/null
+++ b/app/views/admin/products/new.html.erb
@@ -0,0 +1,27 @@
+ New Product
+
+<%= simple_form_for [:admin, @product] do |f| %>
+
+
+ <%= f.input :title %>
+
+
+
+ <%= f.input :description %>
+
+
+
+ <%= f.input :quantity %>
+
+
+
+ <%= f.input :price %>
+
+
+
+ <%= f.input :image, as: :file %>
+
+
+ <%= f.submit "Submit", data: { disable_with: "Submitting..." } %>
+
+<% end %>
diff --git a/app/views/carts/index.html.erb b/app/views/carts/index.html.erb
new file mode 100644
index 0000000000..bf3713373c
--- /dev/null
+++ b/app/views/carts/index.html.erb
@@ -0,0 +1,65 @@
+
+
+ <%= link_to("清空购物车", clean_carts_path ,
+ method: :delete, class: "pull-right",
+ style: "text-decoration: underline;",
+ data: {confirm: "你确定要清空整个购物车吗"})%>
+
购物车
+
+
+
+ 商品资讯 |
+ 单价 |
+ 数量 |
+ 编辑 |
+
+
+
+ <% current_cart.cart_items.each do |cart_item| %>
+
+
+ <%= link_to product_path(cart_item.product) do %>
+ <% if cart_item.product.image.present? %>
+ <%= image_tag(cart_item.product.image.thumb.url, class: "thumbnail") %>
+ <% else %>
+ <%= image_tag("http//placehold.it/200x200&text=No Pic", class: "thumbnail") %>
+ <% end %>
+ <% end %>
+ |
+
+ <%= link_to(cart_item.product.title, product_path(cart_item.product))%>
+ |
+
+ <%= cart_item.product.price %>
+ |
+
+ <%= form_for cart_item, url: cart_item_path(cart_item.product_id) do |f| %>
+ <%= f.select :quantity, 1..cart_item.product.quantity %>
+ <%= f.submit "更新", data: {disable_with:"Submitting..."} %>
+ <% end %>
+ |
+
+ <%= link_to cart_item_path(cart_item.product_id), method: :delete do %>
+
+ <% end %>
+ |
+
+ <% end %>
+
+
+
+
+
+
+ 总计 <%= render_cart_total_price(current_cart) %> RMB
+
+
+
+
+
+
+
+ <%= link_to("确认结账","#", method: :post, class: "btn btn-lg btn-danger pull-right") %>
+
+
+
diff --git a/app/views/common/_flashes.html.erb b/app/views/common/_flashes.html.erb
new file mode 100644
index 0000000000..04a0891ba3
--- /dev/null
+++ b/app/views/common/_flashes.html.erb
@@ -0,0 +1,8 @@
+<% if flash.any? %>
+ <% user_facing_flashes.each do |key, value| %>
+
+
+ <%= value %>
+
+ <% end %>
+<% end %>
diff --git a/app/views/common/_footer.html.erb b/app/views/common/_footer.html.erb
new file mode 100644
index 0000000000..ac58f03d9f
--- /dev/null
+++ b/app/views/common/_footer.html.erb
@@ -0,0 +1,6 @@
+
diff --git a/app/views/common/_navbar.html.erb b/app/views/common/_navbar.html.erb
new file mode 100644
index 0000000000..2f43f24a6b
--- /dev/null
+++ b/app/views/common/_navbar.html.erb
@@ -0,0 +1,46 @@
+