Commit 0e984652 by Vy Quoc Vu

update source

parent dec4a28a
...@@ -3,7 +3,21 @@ class CartsController < ApplicationController ...@@ -3,7 +3,21 @@ class CartsController < ApplicationController
def show def show
end end
def create
new_cart = Cart.new(cart_params)
new_cart.save
byebug
end
def info def info
@cart = Cart.new
end
def user_params
params.require(:cart).permit(:name, :email, :address)
end
def cart_params
params.require(:session).permit(:name, :mail, :address)
end end
end end
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</ul> </ul>
<div class="row"> <div class="row">
<div class="col-md-10 "> <div class="col-md-10 ">
<%= form_for(:session, url: cart_path) do |f| %> <%= form_for(:session, url: create_cart_path) do |f| %>
<%= f.label :email %> <%= f.label :email %>
<%= f.email_field :email, class: 'form-control' %> <%= f.email_field :email, class: 'form-control' %>
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
<%= f.label :address %> <%= f.label :address %>
<%= f.text_field :address, class: 'form-control' %> <%= f.text_field :address, class: 'form-control' %>
</br> </br>
<%= f.submit "Log in", class: "btn btn-primary" %> <%= f.submit "Log in", class: "btn btn-primary" %>
<% end %> <% end %>
</div> </div>
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
get 'cart_products/:id' => 'cart_products#add' get 'cart_products/:id' => 'cart_products#add'
get 'cart_products/clear' => 'cart_products#clear_cart_product' get 'cart_products/clear' => 'cart_products#clear_cart_product'
get 'cart' => 'carts#info' get 'cart' => 'carts#info'
get 'carts' => 'carts#new'
post 'carts/create' => 'carts#create', as: 'create_cart'
resources :categories, only: [:index, :show] resources :categories, only: [:index, :show]
resources :products, only: [:index, :show] resources :products, only: [:index, :show]
......
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