Chris Oliver

Joined

290,710 Experience
86 Lessons Completed
298 Questions Solved

Activity

Posted in Default Order of Associated Model Collection?

I think it's all an implementation detail of the database you're using. From https://www.postgresql.org/docs/current/queries-order.html

A particular output ordering can only be guaranteed if the sort step is explicitly chosen.

You've probably just gotten lucky with SQLite, etc, in the past. 😅

I think it's reasonable to include the sort order in your tests that way you can make sure both result sets are matching.

Or use something like difference which would compare for the same items regardless of sort order. https://ruby-doc.org/core-2.6/Array.html#method-i-difference

Really depends on what you're trying to verify in the tests. If the order doesn't matter, no difference between the two arrays would be a good alternative assertion.

Posted in Default Order of Associated Model Collection?

I believe Postgres preserves insertion order for simple queries, but when you start getting into more complex where conditions and things it will not. Always good to specify an order if you're expecting a certain order in your results. 👍

Posted in Introduction to Stimulus Reflex Discussion

Not quite yet. For example, I'm trying to build a Trello clone with Stimulus Reflex right now. Everything works great, however when I try to broadcast updates to other browsers, that's going to blow away any editing the other users might be doing. I'm talking with Nate tomorrow about it so hopefully I will have some answers. For right now, it seems real easy if you're just wanting realtime updates for a single user.

Posted in Introduction to Stimulus Reflex Discussion

Exactly. Serialize the whole form and send it over to SR. Stimulus controller would make that the easiest, naturally.

The optimism gem is already built to do that btw. https://github.com/leastbad/optimism

Posted in How to use Action Mailbox in Rails 6 Discussion

Nah, you'd just add those queues to Sidekiq, delayed job, etc.

Make sure your background workers are processing the action_mailbox_routing and action_mailbox_incineration queues.

Hey Ted,

Honestly, I'd just recommend using stimulus-flatpickr as it will do the setup/teardown automatically for you when Stimulus connects. Makes for very simple Turbolinks compatibility.

As for just fixing the flatpickr instance when it renders cache, you're exactly right. That's what you'd want. It will make sure it tears down before Turbolinks caches the HTML and that's exactly what you need.

Stimulus makes it a piece of cake, so I've started moving to creating Stimulus components that do the setup/teardown rather than listening to turbolinks events. It works with Turbolinks, with the additional benefit that it will also setup/teardown whenever you dynamically add HTML to the page from an AJAX request or websocket which is really nice.

Posted in Group Chat with ActionCable: Part 4 Discussion

And you can definitely configure it to only create the websocket connection on the page you want like what you're describing. Just gotta write your JS to detect the page and connect when it's the correct one.

Posted in Group Chat with ActionCable: Part 4 Discussion

Websockets are just designed to be a persistent connection. As you're browsing the site the connection can stay idle until you need it. GitHub, for example, will leave the websocket connection open as you browse but only subscribe to receive events when you view or leave a Pull Request or Issue.

Posted in Group Chat with ActionCable: Part 4 Discussion

ActionCable should be on every page and always connected. You don't want to disconnect and reconnect constantly.

You simply want to ignore updates if they aren't relevant to the page you're looking at.

Posted in Get Email from DataBase for creating newsletter

Check out the Actionmailer guides: https://guides.rubyonrails.org/action_mailer_basics.html

If you had a LeadMailer that sent a new_lead email, it would be:

LeadMailer.with(lead: @lead).new_lead.deliver_later

Posted in Stripe payments course getting out of date

👍 The course will definitely help explain how all the payments stuff works better. Especially now that it's crazy complicated with SCA.

I should make a quick tutorial on one-time payments with Jumpstart Pro, because that's what I'm doing for selling the Jumpstart Pro licenses after all. I'll try and squeeze a screencast in today if I can.

Posted in Stripe payments course getting out of date

@bradley Yeah, I redid the whole thing but turned it into a separate course: https://courses.gorails.com/payments-with-rails-master-class

Covers one-time payments with a shopping cart example and subscription billing, all of it SCA compatible.

Posted in Tabs with Stimulus

(And hilarious accidentally just commented from my laptop, logged into a testing account).

Posted in Tabs with Stimulus

Haha! I don't want to admit, but I do that pretty regularly too switching between my laptop and desktop. 😅

Posted in Tabs with Stimulus

Hey Brian!

Looks like you've got some invalid HTML there. There's a closing tablerow tr tag, but no opening one and you're missing a closing div for the tabs.panel div?

Posted in Introduction to Stimulus Reflex Discussion

Stimulus Reflex is compatible with AnyCable. 👍

Posted in Tailwind - own components - yes or no?

Adam talks about this in one of the Tailwind videos. I'll let him explain it cuz he can do a better job than me. https://twitter.com/adamwathan/status/1245883595396386816

Posted in Introduction to Stimulus Reflex Discussion

It looks like they're going to be releasing some improvements to Turbolinks and things soon (when they launch Hey.com) that are similar to this. Can't wait to see what they release.