David Kimura PRO
Joined 7/18/2015
Drifting Ruby Owner
Ruby Rogues Panelist
David Kimura PRO said 4 months ago on Soft Limits :
  torrentdu64 The limit and offset is to grab the number of records to be "deactivated" 

limit = user.books.count - user.resource_limit
this is getting the total number of books and subtracting the soft limit that the user has set. So if there are 10 books and the user is allowed to have 4 then the limit will be set to 6. "limit" is probably a bad name because it really is number_of_books_over_the_limit.

The limit method will only return that number of books (performing a SQL LIMIT) whereas offset will return all of the records, offsetting from whatever number it is.So, in this case, we deactivated the records up to 6, but then activated the rest of them (offsetting from 6), so that should be the 4 allowed records within the soft limits implementation.

David Kimura PRO said 4 months ago on Soft Limits :
  lrjbrual I would have a look at the webhooks implementation in this episode https://www.driftingruby.com/episodes/webhooks-from-stripe-billing-portal. Whenever there is a change plan or charge succeeded event, I would simply look up their subscription and then call the update to the user's resource limit and the updating of the resources.

David Kimura PRO said 4 months ago on Processing Large Jobs :
You can, but typically, I don't like passing "complex" objects into background jobs as parameters. I know that Global Id is just a string and that would work, but it always feels better to be a bit more explicit with what I'm passing instead of passing an Object which gets converted into a String. So, I think it may be more of a personal choice/style.

David Kimura PRO said 3 months ago on Kanban from Scratch Part 2 :
  richard_wiltshire  I've updated the code. For some reason, I didn't have it committed and sent up the previous episodes. I wish I could say that this is the first time that this has happened. The zipped code has also been updated. I think that there is a caching issue going on so the Code browser tab isn't reflecting the latest code.

David Kimura PRO said 3 months ago on Dependent Fields with Hotwire :
It's just a "fancy" way to add the data-action without having to add it manually. It does lose some visibility within the HTML view that there is an action that will be triggered, but given the stimulus controller's functionality, it would be expected. If you had many toggles on the same page, the extra noise could be distracting and also leave more room for errors.