Shopping Cart Order Sessions In Rails 7 With Turbo

  Рет қаралды 8,361

Deanin

Deanin

Күн бұрын

Пікірлер: 23
@Deanin
@Deanin 2 жыл бұрын
Build a Linktree Clone Course learn.deanin.com/courses/build-a-linktree-on-rails Edit: As pointed out in the comments, your price could probably be an integer instead of a decimal, as that's how Stripe stores the value. Which means you'll have to convert for decimal displays. Had a few people contact me to say that the previous shopping cart tutorial doesn't work in Rails 7. So here's a bonus holiday video to hopefully address this ASAP.
@josbexerra8115
@josbexerra8115 2 жыл бұрын
Excelete tutorial mister Dean, los curso estan sutitulados en ingles
@fugeeohu9357
@fugeeohu9357 Жыл бұрын
What should I do with all the records in the orderables table after checkout is completed? Since there are many orderables to an order and I only want to create one row in the orders table
@vaibhavshankarjoshi
@vaibhavshankarjoshi 2 жыл бұрын
How can we implement catagory and subcategories? also is it possible that we can make admin and user so that user can only bye things and admin can only add or remove catagory subcategories and products
@SupeRails
@SupeRails 2 жыл бұрын
0:44 why decimal, not integer? Stripe for example stores amounts in integer 4:03 I would have used @cart = Cart.find_or_create_by(id: session[:cart_id]) - less code to write. or even better - create a cart only when the first product is being added to the cart. That way we don't have an empty cart for each session without added cart_items...
@Deanin
@Deanin 2 жыл бұрын
Combination of not knowing how Stripe stores it and wanting to cover how to set decimal precision lol. I'll update the pinned comment, thanks!
@Drill2411
@Drill2411 2 жыл бұрын
What do you think about your purchase history?
@Deanin
@Deanin 2 жыл бұрын
That's probably something that I would implement after setting up Stripe because stripe gives you the ability to request a user's payment history. Which is also a good way to validate that the user actually owns the product and hasn't done something fishy like issued a chargeback. I can take a look at setting something like that up for a potential part 2.
@scottm.2490
@scottm.2490 2 жыл бұрын
Hi at 17:35 you use the syntax `current_orderable.update(quantity:)` I was expecting `current_orderable.update(quantity: quantity)` could you help me better understand how `current_orderable.update(quantity:)` works and why you dont have to pass in the value? Thanks
@saadshoukat
@saadshoukat Жыл бұрын
Find Any Answer?
@mefitdev
@mefitdev Жыл бұрын
I just saw this, I was trying to find the same answer. Let say we have the following: custom_attribute = "foo" While calling a function, if we add the colon after the name of the variable, a new hash will be passed having the name of the variable as the hash key, and the value of the variable as the hash value. Like: function_call(custom_attribute:) == function_call({custom_attribute: "foo"})
@ddevulders
@ddevulders 10 ай бұрын
This is the new hash syntax introduced in Ruby 3 AFAIK. It's to adhere to the DRY principle (Do not repeat yourself) so instead of constantly calling method: method. you just say method:. This will automaticly invoke the local variable or method with the same name in it's specific scope.
@devatif
@devatif 7 ай бұрын
That's basically update in Ruby following the DRY principle, If you use RUBOCOP and write that syntax, it will automatically set to use the DRY principle i.e. `current_orderable.update(quantity:)` instead of `current_orderable.update(quantity: quantity)`
@joereeve2569
@joereeve2569 2 жыл бұрын
My cart gets erased every time I navigate to a new page, any idea what might be happening here?
@joereeve2569
@joereeve2569 2 жыл бұрын
Missed an equal sign in the initialize_cart method..
@danbenjamin5165
@danbenjamin5165 2 жыл бұрын
Excellent tutorial, but I'm getting an error cart_controller.rb:11: syntax error, unexpected ')' ...ent_orderable.update(quantity:) on any line that includes update(quantity:). Has anyone else run into this issue? @deanin?
@PaprykaKonserwowa
@PaprykaKonserwowa 2 жыл бұрын
hi, I've updated Ruby, Rails, bundler and it works. Now I only have some issues with turbo but I'll investigate that part later.
@andrewkancev6035
@andrewkancev6035 2 жыл бұрын
Same problem
@andrewkancev6035
@andrewkancev6035 2 жыл бұрын
and - undefined method `orderables' for nil:NilClass
@mefitdev
@mefitdev Жыл бұрын
If you don't want to update everything, you can just: .update(quantity: quantity). Explanation: (This works on newer rails, ruby, bundler versions) Let say we have the following: custom_attribute = "foo" While calling a function, if we add the colon after the name of the variable, a new hash will be passed having the name of the variable as the hash key, and the value of the variable as the hash value. Like: function_call(custom_attribute:) == function_call({custom_attribute: "foo"})
@kaygee1m
@kaygee1m Жыл бұрын
When you add more of the same product, it needs to add to that quantity of that product, not replace it! Otherwise, it's not really an "add"!
@jhonnatasalencar4476
@jhonnatasalencar4476 Жыл бұрын
Just replace : current_orderable.update(quantity:) for current_orderable.update(quantity: current_orderable.quantity + quantity)
@dianas1720
@dianas1720 Жыл бұрын
Hi, I'm getting this error message and I want to cry, I have tried so many different solutions, but I'm still stucked! can you please help? NoMethodError in CartsController#remove undefined method `destroy' for nil:NilClass Extracted source (around line #20): def remove Orderable.find_by(id: params[:id]).destroy end end
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 4 МЛН
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 4,1 МЛН
У вас там какие таланты ?😂
00:19
Карина Хафизова
Рет қаралды 27 МЛН
Create A Tailwind CSS Project w/ Rails 7, Stimulus
18:16
Deanin
Рет қаралды 11 М.
React SPA With JSX Using ESBuild In Ruby On Rails 7
14:03
Deanin
Рет қаралды 10 М.
Stripe Checkout in Rails with the Pay gem
17:49
GoRails
Рет қаралды 13 М.
Turbo Frame Pages in Ruby on Rails 7
15:47
Deanin
Рет қаралды 8 М.
Session Based Shopping Cart on Rails
52:20
Kyle Geske
Рет қаралды 8 М.
RailsConf 2017: A Deep Dive Into Sessions by Justin Weiss
32:42
Running Multiple Databases In Ruby On Rails 7
12:28
Deanin
Рет қаралды 4,8 М.
What Are Svelte Stores - Ecommerce Shopping Cart Example
9:17
SvelteRust
Рет қаралды 1,2 М.