Commit 0e984652 by Vy Quoc Vu

update source

parent dec4a28a
......@@ -3,7 +3,21 @@ class CartsController < ApplicationController
def show
end
def create
new_cart = Cart.new(cart_params)
new_cart.save
byebug
end
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
......@@ -17,7 +17,7 @@
</ul>
<div class="row">
<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.email_field :email, class: 'form-control' %>
......@@ -28,7 +28,6 @@
<%= f.label :address %>
<%= f.text_field :address, class: 'form-control' %>
</br>
<%= f.submit "Log in", class: "btn btn-primary" %>
<% end %>
</div>
......
......@@ -9,6 +9,8 @@
get 'cart_products/:id' => 'cart_products#add'
get 'cart_products/clear' => 'cart_products#clear_cart_product'
get 'cart' => 'carts#info'
get 'carts' => 'carts#new'
post 'carts/create' => 'carts#create', as: 'create_cart'
resources :categories, 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