Chris Oliver

Joined

292,970 Experience
93 Lessons Completed
295 Questions Solved

Activity

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

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?

Posted in Realtime Notifications with ActionCable Discussion

You're welcome! 🤓

Posted in Muliple has_one's on a polymorphic association

Hmm, I wonder if you need to include the address ID in the form as a hidden field so Rails knows which records to update. If it doesn't have the ID of the nested model, it is just going to create a new one, so that might be what's happening here. It seems like it's creating new records instead of updating the old ones. Does that sound right?

Posted in In-App Messages Between Users Discussion

Just pass in the user_id in the URL on the link, and then set it as a hidden field inside the form rather than a select tag. That should do the trick!

Posted in Authorization With CanCanCan Discussion

Maybe you didn't add a role string field to your model? That's usually the case when you run into that error.

Posted in Basic Authentication and RSS Feeds Discussion

Oh yeah :) I use Wistia to host them all. They upload them to S3 (or wherever they use) and probably serve the files up through a CDN. I let them handle it but if I were to do it myself I would use S3 and CloudFront probably.

It should just pick up the searchbox ENV variable and work. Depending on how many models you're indexing, you'll need the correct number of shards available (some of the ES options limit shards or other things).

Posted in Basic Authentication and RSS Feeds Discussion

@episodes is the instance variable you'd set in the controller just like you normally would when printing out the index.

Posted in Multiple Users with Devise

Welcome! :)

The simplest way to go about this is probably to create just one User type but add a role attribute to it. Just make it a string to keep it simple. When you sign up, you can choose either Student or Teacher. Depending on hwich one you select, submit the string "student" or "teacher" for the role field so it can get saved to the database.

You can use that role attribute to redirect them easily. Then you can have to different types of profiles in your database. StudentProfile, and TeacherProfile. You can put any of the fields you want to have on those, and then ask them to fill out the correct type of profile after signing up based on their role.

Let me know how it works out!

Posted in Russian Doll Caching with Rails 5 Discussion

Yep, you'd need to include that in the cache key so they are all separated out cleanly. Don't want to be leaking any of that information between schemas.