Chris Oliver

Joined

290,710 Experience
86 Lessons Completed
298 Questions Solved

Activity

Posted in In-App Navbar Notifications - GoRails

I would just create one notification record for each user you want to send it to. You need to do that anyways so you can mark when each user read their notification if you want to add that feature in the future. So normally you would just do a loop, find all the users you want to notify, and then create a Notification record for each user.

Posted in How ActionCable Uses Redis Discussion

Yeah that's going to be an interesting one. Presumably you'll end up needing to build a cluster of dedicated actioncable servers and maybe you connect 100 users to each at a maximum. At some point as well, you'll probably run into Redis pubsub scaling problems, but that hopefully isn't a bottleneck right away.

Posted in Solving FizzBuzz in Ruby Discussion

Oh you know what, I probably had access to ActiveSupport while I was doing that.

Add this line at the beginning if you have the active_support gem installed.

require 'active_support/core_ext'

The blank? method doesn't come from Ruby but most of my work being in Rails I'm so used to having it around. :)

Posted in In-App Navbar Notifications - GoRails

I'm not sure, but compare your code against the source code of mine that's linked in the episode notes. I'm sure you'll figure it out! :)

Posted in In-App Navbar Notifications - GoRails

No, you don't need to because it will check for the action's json.jbuilder template. Just make sure you created that file and it's index.json.jbuilder in the app/views/notifications folder.

I've been realizing I need to make that transition soon anyways just because there are way too many screencasts to keep track of at this point. :)

I'll probably be migrating to a bunch of small series over the next few weeks!

👍🎉

Posted in Comments With Polymorphic Associations Discussion

Awesome! You're welcome! :D

Posted in Comments With Polymorphic Associations Discussion

Hmm, I was hoping it wasn't. Usually it's just that the user isn't signed in. Otherwise...I'm not entirely sure. There aren't a whole lot of places to go check to make sure things are correct aside from that.

Possibly just a typo in your comment, but make sure you've got:

@comment.user_id = current_user.id

If you specify user_id, then you need to specify ID on the user, or you can just assign the object to the association alternatively:

@comment.user = current_user

Posted in Comments With Polymorphic Associations Discussion

Is the user not currently signed in by chance when you submit a comment?

Posted in Comments With Polymorphic Associations Discussion

Just ignore that part and add the order and limit functions to your call when you retrieve comments. That's the important bit there.

Posted in Comments With Polymorphic Associations Discussion

You could change it to the following:

<% commentable.comments.order(created_at: :desc).limit(5).each do |comment| %>

Posted in Sharing Data With Javascript Discussion

You can use this approach still the exact same way with ActionCable if you want to preload some data in the view before the Websocket connection gets initialized.

For the most part, with websocket stuff, I imagine in most cases you will want to just display a loading spinner instead while the connection gets setup. They'll happily work together though with no problem. The only difference is that you change the mechanism to update the data from AJAX to Websockets.

Posted in Stripe Subscription with Initial setup fee

Hey Nick,

I remember looking this up before, and I believe the recommended thing from Stripe was to basically create a Charge for $10 and then also setup the user on a Subscription at the same time, but give them a 30 day trial. That way you get your setup fee and first month, but the real subscription doesn't start until a month later.

Just googled it again, turns out you can set the account_balance now instead. https://support.stripe.com/questions/subscription-setup-fees This is much easier!

You should be able to just follow my Stripe screencasts and pass in this extra parameter and you'll be good to go!

Posted in Setup MacOS 10.12 Sierra Discussion

I haven't actually tested this personally just yet. :) I've got reports it worked great. Are you having issues with it?

Posted in Improving In-App Notifications Discussion

Also, the ActionCable episode! Just posted it! https://gorails.com/episode...

Posted in Improving In-App Notifications Discussion

Posted in Improving In-App Notifications Discussion

So those are just the normal dropdowns for Bootstrap, but I've added in some divs inside the elements instead of it just being one-liners and the following CSS:

.dropdown-menu .notification {
&.unread {
a {
border-left: 4px solid $red;
}
}

a {
padding: 10px 20px;
}

.avatar {
height: 24px;
margin-right: 10px;
width: 24px;
}
}

I don't know a whole lot about OpenID and it's always been a little confusing to me when I've read about it.

I think that if you used the omniauth-openid-connect with this episode and replaced the Twitter omniauth gem with that one, you could do it with relatively easy changes: https://gorails.com/episodes/omniauth-twitter-sign-in

Do you have an example of one that you'd like to see?