Commit 5e245ce1 by Dao Minh Nhut

solr search, insert, update, delete

parents d38e9224 f67de3d0
class Admins::UsersController < ApplicationController
<<<<<<< HEAD
before_action :authenticate_admin!
=======
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
def show
@users = User.paginate(page: params[:page]).per_page(25)
end
<<<<<<< HEAD
def delete
@user = User.find(params[:id])
@user.destroy
redirect_to :back
end
=======
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
end
......@@ -18,7 +18,17 @@ class CartsController < ApplicationController
@new_cart = Cart.new(fullname: params[:cart][:fullname], email: params[:cart][:email],
address: params[:cart][:address], phone: params[:cart][:phone],
total_price: calculate_total_price, status: "new cart", user_id: cart_user_id)
<<<<<<< HEAD
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|
cart_product = CartProduct.new
cart_product.cart_id = @new_cart.id
......
......@@ -7,8 +7,11 @@ class CategoriesController < ApplicationController
rescue
redirect_to root_path
end
<<<<<<< HEAD
end
def index
redirect_to root_path
=======
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
end
end
\ No newline at end of file
......@@ -5,4 +5,8 @@ class Product < ActiveRecord::Base
validates :name, :image, presence: true, length: { maximum: 1000 }
validates :description, length: { maximum: 65535 }
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
<% if admin_signed_in? %>
<<<<<<< HEAD
<div class="span12">
<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">
<thead>
<tr>
......
VenShop::Application.routes.draw do
<<<<<<< HEAD
=======
namespace :admins do
get 'users/new'
end
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
devise_for :users
devise_for :admins
namespace :users do
......
......@@ -4,7 +4,7 @@ class CreateProducts < ActiveRecord::Migration
t.string :name
t.string :image
t.integer :price
t.string :description, limit: 65535
t.string :description
t.integer :category_id
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 @@
#
# 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: 20150804082910) do
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
create_table "admins", force: :cascade do |t|
t.string "email", limit: 255, default: "", null: false
......
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
User_id: 1
user_id: 1
total_price: 1
status: MyString
fullname: MyString
phone: 1
phone: MyString
address: MyString
email: MyString
two:
User_id: 1
user_id: 1
total_price: 1
status: MyString
fullname: MyString
phone: 1
phone: MyString
address: 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