Watched 1 video

Watched 1 Video from start to finish

Subscribed for 1 month

Learning and showing your support for 1 Month

Spread the word 1 time

Referred 1 Member to Drifting Ruby

10

10 times Chatter Box

Make 10 comments to videos or replies to other comments
5/10

10

Share the love 10 times

Liked 10 episodes
1/10

3

Welcome back 3 times

You've visited Drifting Ruby on 3 different days

Suggested 1 episode

Helped the community by suggesting 1 episode

Vote Suggestion 1 time

Helped the community by voting on suggestions 1 time

Share the love 1 time

Liked 1 episode

Earned on 3/4/2019

1 time Chatter Box

Make 1 comment to videos or replies to other comments

Earned on 3/4/2019

Michael Law said almost 3 years ago on Decoding and Interacting with Barcodes :

Hey, I was having trouble once the barcode is captured/scanned. In the console it has the error, ""POST http://localhost:3000/products/get_barcode 404 (Not Found)". I have checked my routes and run rake routes, and they are coming up correctly. Any idea why that may be?

Michael Law said almost 3 years ago on Decoding and Interacting with Barcodes :

I copied and pasted the code as you have it below, except my routes have 'orders' where you have 'products', and I'm only trying to find already existing orders.

The only difference is that my 'orders' routes are actually nested.

In my JS file, I have everything else exactly the same except the url in the ajax request.

$.ajax({
  type: "POST",
  url: '/orders/get_barcode',
  data: { upc: code }
});

Since my orders route is nested, when I run rake routes I get

get_barcode_ticket_orders ... POST ... /tickets/:ticket_id/orders/get_barcode(.:format) ... orders#get_barcode


In my routes file:

resources :tickets do
    resources :orders do
      post :get_barcode, on: :collection
    end
  end

Michael Law said almost 3 years ago on Decoding and Interacting with Barcodes :

I was just about to ask you if it was throwing the error because I'm not passing the ticket_id. I'm not the best with jQuery so I didn't know if the client required that, although as I type it this makes sense that it would.

What do you mean by "pass it into the data attribute"?

Are you saying that the client is throwing the original error I posted because it's trying to find the order, but doesn't have the ticket_id?

Michael Law said almost 3 years ago on Decoding and Interacting with Barcodes :

Hm. That's a problem because at this point the ticket_id is not accessible for me to put it in a div. Are there any other ways you can think of to do this? You don't have to write out the code, you can just let me know your ideas.

Michael Law said almost 3 years ago on Decoding and Interacting with Barcodes :

I wasn't able to figure it out, and even utilizing the hints you gave me didn't change much. All the errors are popping up in the console on the client. I'm not a jQuery guy, so I'll have to look into another solution for accomplishing this. Thanks for your help and the video is great!