Înapoi la articole →

Cel mai recent articol

Ultima verificare

Urmăritori 0 urmăritori
Articole: 90
  1. Sometimes just using preload or includes is not possible… or maybe it is, but you just can’t figure it out how to do it.

  2. Maybe you are already familiar with includes or preload, but you know that a lot of the time you will need more than just preload(:comments).

  3. An n+1 queries problem means that a query is executed for every result of a previous query.

  4. A common cause of n+1 queries is fetching the “latest-N-of-each” record on a list of records.

  5. There are different practices, that I know, to test that an email was sent in Rails… Check for the ActionMailer::Base.deliveries Spy your own sender objects Use doubles for your mailer objects All of them have pros and cons and will help you test different

  6. If you want to test that an email was sent on a system spec in rails… What you can do is to check the ActionMailer::Base.deliveries to see if the email that you want is there.

  7. As you may now there are two hard things in computer science and one of them is naming things.

  8. I like heroku, it is very easy to use, but sometimes you just can’t use it… Maybe it is too expensive for your project.

  9. Maybe your are thinking that you should just use Heroku and move on with your life.

  10. For most of us, heroku is a really useful tool because it does so much for us, but in some cases it could look like it is really expensive… … Is it really expensive?

  11. Imagine that you need to query for the payments received the “week before” of a given date.

  12. Imagine that you need to query for the records created in the “week before” of a given date.

  13. This was new for me, I was looking how to get the noCertificado from a CSD (Certificado de Sello Digital) and I found it is the serial of the certificate but in base 2.

  14. Do you want to test a PDF download with capybara, but don’t know how to do it?

  15. Do you need/want to test a CSV download with capybara, but don’t know how to do it?

  16. A code sample of a “read-more” behavior using the rails truncate method and Stimulus.js.

  17. I have already shared a way of implementing a “read-more” behavior truncating by the number of lines instead of the number of words.

  18. Are you looking for a way of implementing a “read-more” behavior truncating by the number of lines instead of the number of words?

  19. Capybara cheatsheet

    Are you working with capybara?

  20. Imagine that you want to refactor this… expect(row).to have_css("[data-role=description]", text: "Desc 1") expect(row).to have_css("[data-role=amount]", text: "$250.00") into this… expect(row).to display_entry_with("Desc1", $250.00) What would you do?

  21. There are many tools that can help you detect n+1 queries in different ways.

  22. Do you need more practice to understand the difference between “includes”, “preload”, “eager_load” and “joins”?

  23. I am currently working on a kind of “presentation object” that I called IdealPayments::GlobalStats.

  24. Do you know “in theory” the difference between “includes”, “preload”, “eager_load” and “joins”, but you still think that you need more examples to really understand how to use them?

  25. Do you know “in theory” the difference between “includes”, “preload”, “eager_load” and “joins”, but you still think that you need more examples to really understand how to use them?

  26. Are you using Active Storage to handle file uploading to the cloud (maybe AWS) and you want to know how to attach an uploaded file to an email?

  27. Even if you already know what is the difference between includes, preload and eager_load, maybe is not that clear when is better for you to use one vs the other.

  28. Are you dealing with includes, preload, eager_load and joins, maybe fixing some n+1 queries, but you are not really sure what’s the difference between all of them?

  29. A common cause of n+1 queries is fetching the “latest-N-of-each” record on a list of records.

  30. Do you struggle fixing N+1 queries because is hard for you to detect why ActiveRecord seems to ignore your “includes”?

  31. Do you have a method that works fine with a single record, but when you use it on a list causes N+1 queries?

  32. When you are trying to solve an n+1 problem, hopefully you will find different ways to solve it.

  33. What fix should you pick for your “latest-comment” n+1 queries problem?

  34. Do you have to fetch the latest “x” of each record?

  35. Do you have to fetch the latest “x” of each record?

  36. What fix should you pick for your n+1 queries problem?

  37. Do you have a method that works fine with a single record, but when you use it on a list causes N+1 queries?

  38. Have you been stuck trying to build a form to save more than one record?

  39. Have you ever implemented a feature that does work, but has resulted in using multiple conditionals in your controller and views… Wondering if there is a better way to do what you just did?

  40. Do you have a method that works fine with a single record, but when you use it on a list causes N+1 queries?