Commit 5e245ce1 by Dao Minh Nhut

solr search, insert, update, delete

parents d38e9224 f67de3d0
class Admins::UsersController < ApplicationController class Admins::UsersController < ApplicationController
<<<<<<< HEAD
before_action :authenticate_admin! before_action :authenticate_admin!
=======
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
def show def show
@users = User.paginate(page: params[:page]).per_page(25) @users = User.paginate(page: params[:page]).per_page(25)
end end
<<<<<<< HEAD
def delete def delete
@user = User.find(params[:id]) @user = User.find(params[:id])
@user.destroy @user.destroy
redirect_to :back redirect_to :back
end end
=======
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
end end
...@@ -18,7 +18,17 @@ class CartsController < ApplicationController ...@@ -18,7 +18,17 @@ class CartsController < ApplicationController
@new_cart = Cart.new(fullname: params[:cart][:fullname], email: params[:cart][:email], @new_cart = Cart.new(fullname: params[:cart][:fullname], email: params[:cart][:email],
address: params[:cart][:address], phone: params[:cart][:phone], address: params[:cart][:address], phone: params[:cart][:phone],
total_price: calculate_total_price, status: "new cart", user_id: cart_user_id) total_price: calculate_total_price, status: "new cart", user_id: cart_user_id)
<<<<<<< HEAD
if @new_cart.save if @new_cart.save
=======
#new_cart.total_price = calculate_total_price
#new_cart.status = "new cart"
#if user_signed_in?
# new_cart.user_id = current_user.id
#end
if @new_cart.save
#if !new_cart.id.nil?
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
session[:cart].each do |id, quantity| session[:cart].each do |id, quantity|
cart_product = CartProduct.new cart_product = CartProduct.new
cart_product.cart_id = @new_cart.id cart_product.cart_id = @new_cart.id
......
...@@ -7,8 +7,11 @@ class CategoriesController < ApplicationController ...@@ -7,8 +7,11 @@ class CategoriesController < ApplicationController
rescue rescue
redirect_to root_path redirect_to root_path
end end
<<<<<<< HEAD
end end
def index def index
redirect_to root_path redirect_to root_path
=======
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
end end
end end
\ No newline at end of file
...@@ -5,4 +5,8 @@ class Product < ActiveRecord::Base ...@@ -5,4 +5,8 @@ class Product < ActiveRecord::Base
validates :name, :image, presence: true, length: { maximum: 1000 } validates :name, :image, presence: true, length: { maximum: 1000 }
validates :description, length: { maximum: 65535 } validates :description, length: { maximum: 65535 }
validates :price, :numericality => { :greater_than_or_equal_to => 0, :less_than_or_equal_to => 99999999 } validates :price, :numericality => { :greater_than_or_equal_to => 0, :less_than_or_equal_to => 99999999 }
<<<<<<< HEAD
=======
validates :page, :numericality => { :greater_than_or_equal_to => 0 }
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
end end
<% if admin_signed_in? %> <% if admin_signed_in? %>
<<<<<<< HEAD
<div class="span12"> <div class="span12">
<h2>Products</h2> <h2>Products</h2>
=======
<div class="span12">
<h2>Products</h2>
<%= link_to "Insert Product", insert_product_path, class: "pull-right"%>
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
<table class="table table-striped table-hover"> <table class="table table-striped table-hover">
<thead> <thead>
<tr> <tr>
......
VenShop::Application.routes.draw do VenShop::Application.routes.draw do
<<<<<<< HEAD
=======
namespace :admins do
get 'users/new'
end
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
devise_for :users devise_for :users
devise_for :admins devise_for :admins
namespace :users do namespace :users do
......
...@@ -4,7 +4,7 @@ class CreateProducts < ActiveRecord::Migration ...@@ -4,7 +4,7 @@ class CreateProducts < ActiveRecord::Migration
t.string :name t.string :name
t.string :image t.string :image
t.integer :price t.integer :price
t.string :description, limit: 65535 t.string :description
t.integer :category_id t.integer :category_id
t.timestamps null: false t.timestamps null: false
......
class ChangeLimit < ActiveRecord::Migration
def change
change_column :products, :price, :integer, :limit => 5
change_column :products, :description, :string, :limit => 20000
change_column :cart_products, :cart_id, :integer, :limit => 5
change_column :cart_products, :product_id, :integer, :limit => 5
change_column :cart_products, :quantity, :integer, :limit => 5
change_column :cart_products, :price, :integer, :limit => 5
change_column :carts, :user_id, :integer, :limit => 5
change_column :carts, :total_price, :integer, :limit => 5
change_column :products, :name, :string, :limit => 1000
change_column :products, :category_id, :integer, :limit => 5
end
end
...@@ -11,7 +11,11 @@ ...@@ -11,7 +11,11 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
<<<<<<< HEAD
ActiveRecord::Schema.define(version: 20150811014432) do ActiveRecord::Schema.define(version: 20150811014432) do
=======
ActiveRecord::Schema.define(version: 20150804082910) do
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
create_table "admins", force: :cascade do |t| create_table "admins", force: :cascade do |t|
t.string "email", limit: 255, default: "", null: false t.string "email", limit: 255, default: "", null: false
......
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one: one:
User_id: 1 user_id: 1
total_price: 1 total_price: 1
status: MyString status: MyString
fullname: MyString fullname: MyString
phone: 1 phone: MyString
address: MyString address: MyString
email: MyString email: MyString
two: two:
User_id: 1 user_id: 1
total_price: 1 total_price: 1
status: MyString status: MyString
fullname: MyString fullname: MyString
phone: 1 phone: MyString
address: MyString address: MyString
email: MyString email: MyString
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment