Commit d38dc405 by Nguyen Quoc Kien

first

parent 822f1eba
...@@ -12,8 +12,10 @@ class CartsController < ApplicationController ...@@ -12,8 +12,10 @@ class CartsController < ApplicationController
def update def update
@cart = Cart.find(session[:cart_id]) @cart = Cart.find(session[:cart_id])
#@user = User.find(@cart.user_id) @user = User.find(@cart.user_id)
@user.update(address: params['cart']['address'], phone: params['cart']['phone'])
@cart.update(cart_params) @cart.update(cart_params)
@cart.update(status: "checkout")
OrderNotifier.received(@cart).deliver OrderNotifier.received(@cart).deliver
session[:cart_id] = nil session[:cart_id] = nil
respond_to do |format| respond_to do |format|
......
...@@ -16,9 +16,6 @@ ...@@ -16,9 +16,6 @@
<%= f.label :phone %> <%= f.label :phone %>
<%= f.text_field :phone, class: 'form-control' %> <%= f.text_field :phone, class: 'form-control' %>
<%= f.label :status %>
<%= f.text_field :status, class: 'form-control' %>
<br> <br>
<%= f.submit "Save changes", class: "btn btn-primary" %> <%= f.submit "Save changes", class: "btn btn-primary" %>
<% end %> <% end %>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<h3 title="<%= product.name %>"><%= truncate(product.name, length: 25) %></h3> <h3 title="<%= product.name %>"><%= truncate(product.name, length: 25) %></h3>
</div> </div>
<p><b>Price: </b><%= number_to_currency(product.price/100.000) %></p> <p><b>Price: </b><%= number_to_currency(product.price/100.000) %></p>
<p>Quanlity: <%= text_field_tag :thing, type: "number" %> <p>Quanlity: <%= text_field :number, class: 'form-control' %>
<%= button_to "Add To cart", cart_products_path(product_id: product), :class => "btn btn-primary", :style => "width: 100px" %> <br/><%= link_to "More Info", product, :class => "btn btn-default" %> <%= button_to "Add To cart", cart_products_path(product_id: product), :class => "btn btn-primary", :style => "width: 100px" %> <br/><%= link_to "More Info", product, :class => "btn btn-default" %>
</p> </p>
</div> </div>
......
class AddPhoneToUsers < ActiveRecord::Migration
def change
add_column :users, :phone, :string
end
end
class AddAddressToUsers < ActiveRecord::Migration
def change
add_column :users, :address, :string
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# 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.
ActiveRecord::Schema.define(version: 20150724174931) do ActiveRecord::Schema.define(version: 20150727094623) do
create_table "cart_products", force: :cascade do |t| create_table "cart_products", force: :cascade do |t|
t.integer "cart_id", limit: 4, null: false t.integer "cart_id", limit: 4, null: false
...@@ -68,6 +68,8 @@ ActiveRecord::Schema.define(version: 20150724174931) do ...@@ -68,6 +68,8 @@ ActiveRecord::Schema.define(version: 20150724174931) do
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "username", limit: 255 t.string "username", limit: 255
t.string "phone", limit: 255
t.string "address", limit: 255
end end
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
......
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