Commit 8714b293 by Vy Quoc Vu

search

parent 70904e91
# 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/
# 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/
// Place all the styles related to the admins/carts controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
// Place all the styles related to the admins/users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class Admins::CartsController < ApplicationController
def index
if admin_signed_in?
@carts = Cart.all
end
end
def edit
if admin_signed_in? && !params[:cart][:status].nil? && !params[:cart][:status].empty?
@cart = Cart.find(params[:id])
if @cart.status == params[:cart][:status]
flash[:danger] = "Notthing change!"
redirect_to :back
else
@cart.status = params[:cart][:status]
@cart.save
flash[:success] = "Success!"
redirect_to :back
end
else
flash[:danger] = "Notthing change!"
redirect_to action: :index
end
end
end
......@@ -3,13 +3,14 @@ class Admins::ProductsController < ApplicationController
@product = Product.new
end
def create
if admin_signed_in?
if product_params[:price].to_i >= 0 && product_params[:category_id].to_i > 0 && !product_params[:image].nil?
if product_params[:price].to_i >= 0 && params[:category][:id].to_i > 0 && !product_params[:image].nil? && !product_params[:image].empty? && !product_params[:price].empty? && !product_params[:name].empty? && product_params[:price].to_i <= 999999
product = Product.find_or_create_by(name: product_params[:name]) do |product|
product.image = product_params[:image]
product.category_id = product_params[:category_id]
product.price = product_params[:price]
product.category_id = params[:category][:id]
product.price = product_params[:price].to_i*100
product.description = product_params[:description]
end
flash[:success] = "Success!"
......@@ -23,16 +24,15 @@ class Admins::ProductsController < ApplicationController
def edit
if admin_signed_in?
if product_params[:price].to_i >= 0 && product_params[:category_id].to_i > 0 && !product_params[:image].nil?
if product_params[:price].to_i >= 0 && params[:category][:id].to_i > 0 && !product_params[:image].nil? && !product_params[:image].empty? && !product_params[:price].empty? && !product_params[:name].empty? && product_params[:price].to_i <= 999999
product = Product.find(params[:id])
byebug
product.name = product_params[:name]
product.image = product_params[:image]
product.category_id = product_params[:category_id]
product.price = product_params[:price]
product.category_id = params[:category][:id]
product.price = product_params[:price].to_i*100
product.description = product_params[:description]
product.save
byebug
flash[:success] = "Success!"
redirect_to "/products/#{product.id}"
else
......@@ -57,14 +57,13 @@ class Admins::ProductsController < ApplicationController
else
flash[:danger] = "Only Admin"
end
end
private
def product_params
params.require(:product).permit(:name, :price, :description,
:image, :category_id, :id)
:image, :id)
end
end
\ No newline at end of file
class Admins::UsersController < ApplicationController
def index
if admin_signed_in?
@users = User.all
end
end
end
class ProductsController < ApplicationController
include ApplicationHelper
include CategoriesHelper
def index
@products = Product.paginate(page: params[:page], :per_page => 50)
@search_products = Product.new
end
def show
@product = Product.find(params[:id])
if !Product.find(params[:id]).nil?
@product = Product.find(params[:id])
else
flash[:danger] = "Product not found!"
end
end
def add
def search
if params[:product][:search]
@products = Product.search(params[:product][:search]).paginate(page: params[:page], :per_page => 50)
flash[:success] = "Success!"
else
flash[:danger] = "Danger!"
end
end
end
module Admins::CartsHelper
end
module Admins::UsersHelper
end
......@@ -3,4 +3,8 @@ class Admin < ActiveRecord::Base
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: { maximum: 255 },
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
end
......@@ -4,5 +4,4 @@ class Cart < ActiveRecord::Base
validates :mail, presence: true, length: { maximum: 255 },
format: { with: VALID_EMAIL_REGEX }
belongs_to :user
has_many :cart_product
end
class CartProduct < ActiveRecord::Base
belongs_to :cart
validates :name, presence: true, length: { maximum: 255 }
validates :price, presence: true, length: {maximum: 4}
end
class Category < ActiveRecord::Base
has_many :products
validates :name, presence: true, length: { maximum: 255 }
def new
@category = Category.new
end
# def create
# @category = Category.new
# end
end
class Product < ActiveRecord::Base
belongs_to :category
validates :name, presence: true, length: { maximum: 3000 }
validates :image, presence: true, length: { maximum: 1000 }
validates :description, presence: true, length: { maximum: 65000 }
def self.search(search)
if search
Product.where('name LIKE ?', "%#{search}%")
end
end
end
......@@ -4,4 +4,8 @@ class User < ActiveRecord::Base
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: { maximum: 255 },
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
end
<% if admin_signed_in? %>
<div class="row">
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Email</th>
<th>Name</th>
<th>Price</th>
<th>Address</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<% @carts.each do |cart|%>
<tr>
<td><%= cart.id.to_s %></td>
<td><%= cart.mail.to_s %></td>
<td><%= cart.name.to_s %></td>
<td><%= number_to_currency(cart.total_price/100, :unit => "$")%></td>
<td><%= cart.address %></td>
<%= form_for(cart, url: "/admins/carts/#{cart.id}/edit" ) do |f| %>
<td><%= f.text_field :status, value: cart.status.to_s, size: 10 , class: "create_input" %>
</td>
<td>
<%= f.submit "Submit" , class: "btn btn-primary" %>
</td>
<% end %>
</tr>
<% end -%>
</tbody>
</table>
</div>
<% end %>
<% if admin_signed_in? %>
<h1>Add Products</h1>
<div class="row">
<div class="col-md-3" style=" padding-top: 50px;">
<% if admin_signed_in? %>
<h1>Admin</h1>
<%= render 'layouts/admin' %>
<% end %>
</div>
<div class="col-md-9" style=" padding-top: 50px;">
<%= form_for(@product, url: {action: "create"}) do |f| %>
<%= f.label :name %>
<%= f.text_field :name, value: "", class: 'form-control'%>
<h1>Add product</h1>
<%= form_for(@product, url: {action: "create"}) do |f| %>
<%= f.label :name %>
<%= f.text_field :name, value: "", class: 'form-control'%>
<%= f.label :price %>
<%= f.number_field :price, value: "", class: 'form-control' %>
<%= f.label :price %>
<%= f.number_field :price, value: "", class: 'form-control' %>
<%= f.label :Category %>
<%= collection_select :category, :id, Category.all, :id, :name %>
</br>
<%= f.label :description %>
<%= f.text_area :description, class: 'form-control' %>
<%= f.label :category_id %>
<%= f.number_field :category_id, value: "", class: 'form-control' %>
<%= f.label :description %>
<%= f.text_area :description, class: 'form-control' %>
<%= f.label :image %>
<%= f.text_field :image, class: 'form-control' %>
</br>
<%= f.submit "Submit" , class: "btn btn-primary" %>
<% end %>
</div>
</div>
<%= f.label :image %>
<%= f.text_field :image, class: 'form-control' %>
</br>
<%= f.submit "Submit" , class: "btn btn-primary" %>
<% end %>
<% else %>
<h1>Only Admin</h1>
<% end %>
\ No newline at end of file
<% if admin_signed_in? %>
<div class="col-md-3" style=" padding-top: 50px;">
<% if admin_signed_in? %>
<h1>Admin</h1>
<%= render 'layouts/admin' %>
<% end %>
</div>
<div class="col-md-9" style=" padding-top: 50px;">
<div class="center jumbotron">
<%= image_tag(@product.image)%>
<h3><%= (@product.price/100.to_f).to_s + "$" %></h3>
<%= form_for(@product, url: {action: "edit"}) do |f| %>
<%= f.label :name %>
<%= f.text_field :name, class: 'form-control'%>
<%= f.label :price %>
<%= f.number_field :price, class: 'form-control' %>
<div class="row">
<h1>Update product</h1>
<div class="center jumbotron" >
<%= image_tag(@product.image)%>
</div>
<%= form_for(@product, url: {action: "edit"}) do |f| %>
<%= f.label :name %>
<%= f.text_field :name, value: @product.name, class: 'form-control'%>
<%= f.label :category_id %>
<%= f.number_field :category_id, class: 'form-control' %>
<%= f.label :price %>
<%= f.number_field :price, value: @product.price/100, class: 'form-control' %>
<br>
<%= f.label :Category %>
<%= collection_select :category, :id, Category.all, :id, :name, :selected => @product.category_id %>
</br>
<%= f.label :description %>
<%= f.text_area :description, class: 'form-control' %>
<%= f.label :description %>
<%= f.text_area :description, value: @product.description, class: 'form-control' %>
<%= f.label :image %>
<%= f.text_field :image, class: 'form-control' %>
</br>
<%= f.submit "Submit" , class: "btn btn-primary" %>
<% end %>
</div>
<%= f.label :image %>
<%= f.text_field :image, value: @product.image, class: 'form-control' %>
</br>
<%= f.submit "Submit" , class: "btn btn-primary" %>
<% end %>
</div>
<% else %>
<h1>Only Admin</h1>
......
<h2>Log in Admin</h2>
<div class="col-md-12">
<div class="center jumbotron">
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<% if devise_mapping.rememberable? -%>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end -%>
<% if devise_mapping.rememberable? -%>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end -%>
<div class="actions">
<%= f.submit "Log in" %>
<div class="actions">
<%= f.submit "Log in" %>
</div>
<% end %>
</div>
<% end %>
</div>
<%= render "admins/shared/links" %>
<% if admin_signed_in? %>
<div class="row">
<h1>All users</h1>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<% @users.each do |user|%>
<tr>
<td><%= user.id.to_s %></td>
<td><%= user.email.to_s %></td>
</tr>
<% end -%>
</tbody>
</table>
</div>
<% end %>
<h1>Your Cart</h1>
<div class="col-md-3" style=" padding-top: 50px;">
<% if admin_signed_in? %>
<h1>Admin</h1>
<%= render 'layouts/admin' %>
<% else %>
<div class="col-md-3">
<% if !admin_signed_in? %>
<%= render 'layouts/cart' %>
<%= render 'categories/view' %>
<% end %>
</div>
<div class="col-md-9" style=" padding-top: 50px;">
<div class="col-md-9">
<div class="col-md-12">
<form class="navbar-left" style="padding-left: 0px" >
<%= link_to "Empty Cart" ,'/cart_product/clear' %>
......@@ -48,8 +45,6 @@
<% end -%>
</ul>
</div>
<div class="footer col-md-12">
</br>
</br>
......
<% if !session[:cart].nil? && !session[:cart].empty? %>
<div class="col-md-3" style=" padding-top: 50px;">
<% if admin_signed_in? %>
<h1>Admin</h1>
<%= render 'layouts/admin' %>
<% else %>
<% if !admin_signed_in? %>
<%= render 'layouts/cart' %>
<% end %>
</div>
......
<h1>show cart</h1>
<h1>Show cart</h1>
<div class="col-md-3" style=" padding-top: 50px;">
<% if admin_signed_in? %>
<h1>Admin</h1>
<%= render 'layouts/admin' %>
<% else %>
<% if !admin_signed_in? %>
<%= render 'layouts/cart' %>
<%= render 'categories/view' %>
<% end %>
</div>
<div class="col-md-9" style=" padding-top: 50px;">
<ul>
<% if !@show_cart.nil? %>
<% @show_cart.each do |cart| %>
<h4>
<%= cart.id.to_s + " | "%>
<%= cart.mail.to_s + " | " %>
<%= cart.name.to_s + " | " %>
<%= cart.total_price.to_s + " | " %>
<%= cart.address+ " | " %>
<%= cart.status.to_s %>
</h4>
<% end -%>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Email</th>
<th>Name</th>
<th>Price</th>
<th>Address</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<% @show_cart.each do |cart|%>
<tr>
<td><%= cart.id.to_s %></td>
<td><%= cart.mail.to_s %></td>
<td><%= cart.name.to_s %></td>
<td><%= number_to_currency(cart.total_price/100, :unit => "$")%></td>
<td><%= cart.address %></td>
<td><%= cart.status.to_s %></td>
</tr>
<% end -%>
</tbody>
</table>
<% else -%>
<h2> Your cart Empty </h2>
<% end -%>
......
<div class="col-md-3" style=" padding-top: 50px;">
<% if admin_signed_in? %>
<h1>Admin</h1>
<%= render 'layouts/admin' %>
<% else %>
<div class="col-md-3" >
<% if !admin_signed_in? %>
<%= render 'layouts/cart' %>
<%= render 'categories/view' %>
<% end %>
<%= render 'categories/view' %>
</div>
<div class="col-md-9" style=" padding-top: 50px;">
<div class="col-md-9">
<% @products.each do |product| %>
<div class="col-md-4">
<div class="center jumbotron" style="padding-left : 40px;">
<%= image_tag(product.image, size: "170x210")%>
<div style="padding-left : 20px;">
<%= image_tag(product.image, size: "180x230")%>
<h5><%= truncate(product.name, length: 22) %></h5>
<%= (product.price/100.to_f).to_s + "$" %>
</br>
<%= link_to "Info", "/products/#{product.id}", class: "btn btn-lg btn-info" %>
<%= link_to "Buy", "/products/#{product.id}", class: "btn btn-lg btn-danger" %>
<% if admin_signed_in? %>
<%= link_to "Edit", "/admins/products/#{product.id}", class: "btn btn-lg btn-primary" %>
<%= link_to "delete", "/admins/destroy/#{product.id}", class: "btn btn-lg btn-danger" %>
<%else %>
<%= link_to "Info", "/products/#{product.id}", class: "btn btn-lg btn-info" %>
<%= link_to "Buy", "/products/#{product.id}", class: "btn btn-lg btn-danger" %>
<%end %>
</div>
</div>
<% end -%>
......
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<div class="col-md-12">
<div class="center jumbotron">
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
......@@ -37,3 +38,5 @@
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<%= link_to "Back", :back %>
</div>
</div>
<h2>Sign up Devise</h2>
<div class="col-md-12">
<div class="center jumbotron">
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :password %>
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password %>
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
<% end %>
</div>
</div>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
......@@ -2,7 +2,6 @@
<h1>Your Cart</h1>
<ul>
<% total = 0 %>
<%byebug%>
<% if !@cart_product.nil? %>
<% @cart_product.each do |id, quantity| %>
<% product = Product.find_by_id(id) %>
......
<h3>Home</h3>
<h3>Categories</h3>
<h3>Products</h3>
<h3>Cart</h3>
\ No newline at end of file
<div id="sidebar-wrapper" style = "padding-top: 0px;">
<ul class="sidebar-nav">
<li class="sidebar-brand">
<h3><%=link_to("Home", root_path )%></h3>
</li>
<li>
<h3><%=link_to("Products", new_admins_product_path )%></h3>
</li>
<li>
<h3><%=link_to("Carts", '/admins/carts' )%></h3>
</li>
<li>
<h3><%=link_to("Users", '/admins/users' )%></h3>
</li>
</ul>
</div>
\ No newline at end of file
......@@ -4,19 +4,11 @@
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href= "/index" > Venshop </a>
<a class="navbar-brand" href= "/" > Venshop </a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="collapse">
<ul class="nav navbar-nav">
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search" style="width: 300px;">
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<% if user_signed_in? || admin_signed_in? %>
<li>
......
......@@ -8,9 +8,17 @@
<%= render 'layouts/shim' %>
</head>
<body>
<% if admin_signed_in? %>
<%= render 'layouts/admin' %>
<% end %>
<div class="container">
<%= render 'layouts/header' %>
<%= yield %>
<div class="container" class="col-md-12">
<% flash.each do |message_type, message| %>
<div class="alert alert-<%= message_type %>"><%= message %></div>
<% end %>
</div>
<%= yield %>
</div>
<%= render 'layouts/footer' %>
</body>
......
......@@ -7,8 +7,7 @@
<%= simple_format(truncate(product.name, length:21)) %>
</div>
<div>
<% price = (product.price/100.to_f) %>
<input type="number" name="quantity" min="1" max="100" value=<%= price %> >
<p> Price: <%= price = (product.price/100.to_f) %> </p>
</br>
<%= link_to "Edit", "/admins/products/#{product.id}", class: "btn btn-lg btn-primary" %>
<%= link_to "delete", "/admins/destroy/#{product.id}", class: "btn btn-lg btn-danger" %>
......
<div class="row">
<div class="col-md-3" style=" padding-top: 50px;">
<% if admin_signed_in? %>
<%= render 'layouts/admin' %>
<% else %>
<div class="col-md-3">
<% if !admin_signed_in? %>
<%= render 'layouts/cart' %>
<%= render 'categories/view' %>
<% end %>
<%= render 'categories/view' %>
</div>
<div class="col-md-9" style=" padding-top: 50px;">
<% flash.each do |message_type, message| %>
<div class="alert alert-<%= message_type %>"><%= message %></div>
<% end %>
<div class="col-md-9" >
<div class="form-group">
<table class="table">
<tr>
<%= form_for(@search_products, url: "search", method: :get) do |f| %>
<th class="col-md-6">
<%= f.text_field :search, value: "" ,class: 'form-control' %>
</th>
<th>
<%= f.submit "Search" , class: "btn btn-primary" %>
</th>
<% end %>
</tr>
</table>
</div>
<% if admin_signed_in? %>
<%= render 'products/admin_products' %>
<% else %>
<%= render 'products/custom_products' %>
<% end %>
</div>
</div>
\ No newline at end of file
<div class="row">
<div class="col-md-3">
<% if !admin_signed_in? %>
<%= render 'layouts/cart' %>
<% end %>
</div>
<div class="col-md-9" >
<% if admin_signed_in? %>
<%= render 'products/admin_products' %>
<% else %>
<%= render 'products/custom_products' %>
<% end %>
</div>
</div>
\ No newline at end of file
<div class="col-md-3" style=" padding-top: 50px;">
<% if admin_signed_in? %>
<h1>Admin</h1>
<% else %>
<%= render 'layouts/cart' %>
<%= render 'categories/view' %>
<% end %>
</div>
<div class="col-md-9" style=" padding-top: 50px;">
<div class="center jumbotron" style="padding-left: 35px;">
<% if !admin_signed_in? %>
<div class="col-md-3">
<%= render 'layouts/cart' %>
<%= render 'categories/view' %>
</div>
<div class="col-md-9">
<% end %>
<div class="center jumbotron">
<%= image_tag(@product.image)%>
<h3><%= simple_format(@product.name) %></h3>
<h3><%= (@product.price/100.to_f).to_s + "$" %></h3>
</br>
<%= simple_format(@product.description) %>
</br>
<form action="/cart_products" style="padding-left: 0px" >
<input type="number" name="quantity" value= "1" min="1" max="100" value="1">
</br>
<input type="submit" value="Add" class = "btn btn-lg btn-success" />
<input type="hidden" name="id" value="<%= @product.id %>"/>
</form>
<% if admin_signed_in? %>
<%= link_to "Edit", "/admins/products/#{@product.id}", class: "btn btn-lg btn-success" %>
<% else%>
<form action="/cart_products" style="padding-left: 0px" >
<input type="number" name="quantity" value= "1" min="1" max="100" value="1">
</br>
<input type="submit" value="Add" class = "btn btn-lg btn-success" />
<input type="hidden" name="id" value="<%= @product.id %>"/>
</form>
<% end %>
</div>
</div>
\ No newline at end of file
<h2>Log in user</h2>
<div class="col-md-12">
<div class="center jumbotron">
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<% if devise_mapping.rememberable? -%>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end -%>
<% if devise_mapping.rememberable? -%>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end -%>
<div class="actions">
<%= f.submit "Log in" %>
<div class="actions">
<%= f.submit "Log in" %>
</div>
<% end %>
</div>
<% end %>
</div>
<%= render "users/shared/links" %>
......@@ -3,17 +3,23 @@
devise_for :users, controllers: { sessions: "users/sessions" }
devise_for :admins, controllers: { sessions: "admins/sessions" }
namespace :admins do
resources :products
resources :products, :carts, :users
end
get 'index' => 'products#index'
get 'login' => 'sessions#new'
get '/admins/destroy/:id' => 'admins/products#destroy', as: 'destroy_product'
get '/admins/carts' => 'admins/carts#index' , as: 'admins_carts_index'
get '/admins/users' => 'admins/users#index'
patch "/admins/products/:id/edit"=>'admins/products#edit'
patch "/admins/carts/:id/edit" => 'admins/carts#edit'
get 'category/:id' => 'category#show'
get 'products/:id' => 'products#show'
post 'search' =>'products#search'
get 'search' =>'products#search'
get 'cart_products' => 'cart_products#add'
get 'cart_product/remove' => 'cart_products#remove'
......
require 'test_helper'
class Admins::CartsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class Admins::UsersControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end
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