-
Notifications
You must be signed in to change notification settings - Fork 19
Homework week2 daniel #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Bootstrap with devise : Login / Logout
* nested attributes * nested form with strong paramets with carrierwave
add cart button
|
【試著回答一下 .. 我也不確定對不對, 希望跟大家一起討論 ~】 # 這個 add_product_to_cart method 讓我很頭痛, 【我的感覺是 current_cart.items.include? 的 method 是從 has_many :items, :through => :cart_items, :source => :product 這串創造而來,而這串的作用意思是「創造一個 :items symbol, 他會去對應「cart_items」這張表,而資料的真正資訊來源是透過 product 這張表,因為在 cart_items 上記錄的都只是 product_id 這樣,這樣會讓原本的物件不知道他自己是誰,所以要再透過 product 去告訴他】 #然後因為現在的功能是要能選擇"數量"放入購物車 【我的方式是因為如果直接透過action是無法處理到更新欄位的問題,除非硬幹用奇怪方法去做什麼記錄..或透過Ajax拿到欄位中的數字去後端記錄,但我覺得這樣第一點有點奇怪,第二點我沒實做,所以最後用法是透過form表單去傳輸,把每個cart_id和cart_item_id導到update action,在把要update的欄位用更新的方式去做到,不過這樣就要安插很多form進去,我也不曉得有沒有更好的做法】 恩..我不是助教,我也正在努力進修,請多多指教 :D |
|
用 cart_items_controller 做 |
|
喔喔 原來我的 branch 只要拉過一次 pull request 之後 ,就不需要再重新拉一次了嗎? 好像我後來的 commit 都會一直上去嗎?
這是本周做完的項目 作業#2 回家作業#3 回家作業#4 作業#5 |
先完成了_清空購物車 & 從購物車內刪掉某些物品 的功能,
但是選擇數量放入購物車卡關了三四個小時了 .... 這樣好像不是辦法..
# 這個 add_product_to_cart method 讓我很頭痛,
看不太懂為什麼有 items 這個東西
然後因為現在的功能是要能選擇"數量"放入購物車
我完全不知道到底該用什麼方法才可以改變 cart_items 這個 table 裡面的 quantity欄位
試過非常多方式,但全都會 error , 助教可以給點提示嗎? 不知道是不是 many to many 的 associate觀念薄弱導致...
不然就又卡住另一個訂單顯示多個數量的功能 ... @@
先來做後面的好了。
謝謝