Chris Oliver

Joined

291,480 Experience
86 Lessons Completed
296 Questions Solved

Activity

Posted in Update an attribute on belongs_to

Hey Alan,

You kind of have two options:

1. Having nested fields for the product_groups. Primarily this would be just letting you add / remove these and then have a select box to choose which group. The gem cocoon would be good for this.
2. Having nested fields for the groups. This skips the product_group and the join association would be automatically created for you. This you could use checkboxes or a multi-select, but it wouldn't let you define other fields on the join table (if you needed to do that). It is a lot simpler though.

Posted in How do I generate dynamic classes?

Posted in Rails Application Templates Discussion

Hey Josh,

Administrate gem just needed updating. Should be fixed now!
I've been using Redis for Rails cache + Sidekiq for years now. Absolutely no problems. There's probably some rare situation that could cause trouble, but I prefer the simplicity of managing less services in production and it's worked just fine.

Posted in Form errors not displaying

No problemo! It's one of those subtleties of Rails that you have to learn the frustrating / hard way. 😜

Posted in Form errors not displaying

Hey RJ!

When you redirect, none of the variables are persisted over because you're making a totally new request. You must `render action: :edit` in the else clause in order to render the errors on the model.

Posted in Open Closed Principle Discussion

For most of this, I knew there was going to be a lot of code so I'd start doing the single responsibility work separation of this code into its own files and folders first. I didn't build this multi-provider thing out until I supported more than just DigitalOcean. 

It's really easy to refactor your code into this, so it's not something you need to start with ahead of time. In fact, trying to follow design patterns too early is often one of the easiest ways to end up with confusing code. Refactoring to apply patterns later on is usually the best approach.

Posted in SQL for search

Hey Robert!

I actually use Ransack to take care of this for me, but it's doing basically exactly that. I make two queries when you search, one for episodes, one for forum threads and then just display them in the autocomplete.

Eventually I might switch to ElasticSearch, but it requires a lot of RAM and probably wouldn't be a huge improvement to the search results anyways. 

Posted in Login with Facebook Discussion

Yeah, unfortunately there's no real action you can take there. It will automatically use their logged in account if it has been previously authorized. The only thing you can do is give them instructions on how to revoke the app on Facebook or tell them to log out. Only Twitter has an option for OAuth to force the user to login that I'm aware of. This is one of the big downsides to OAuth right now that should really be fixed and standardized.

Posted in Login with Facebook Discussion

Ah okay, that makes sense. I think you always still authenticate as a Facebook user, and give access to your pages. So you should have API access to the user to get their pages and then let them choose and you'd just save that choice in your db. To let them remove it and choose again, you'd clear that record from your db, and then present them with the list of pages they manage from the API and save their choice.

Does that make sense? The last time I worked with Facebook pages was quite a few years ago. 

Posted in Login with Facebook Discussion

You can't control the Facebook session (because that would be insecure), but you probably are thinking about this as a developer for testing purposes rather than a user. They'll only have one Facebook account, so when they approve your app, there is no reason to approve it a second time. For you testing, it feels weird, but that's exactly how you'd want it to work for your users.

You can visit your Facebook account's connected apps and revoke it each time if you want to fully reset the OAuth process so you get the approve permissions step each time.

Posted in Stripe's new Billing feature explained?

My idea was basically a way for you to visually map out a product and all the different tiers for it. You can set upgrade rules and so on between them. That's basically what Stripe just rolled out. Plans are attached to Products now and you can add multiple plans to a product.

https://stripe.com/docs/billing/subscriptions/modeling

Posted in Running multiple Rails versions

Yep, it's right. The last version number is a patch version for security and bug fixes. You always want the latest version of that.

The first two versions are the ones that change and break things, so those are the ones to worry about being correct.
Rather than doing something complicated with RPC and all that, why not just have Server A make a POST request to an API on Server B and C? You could simply POST the same data changed over to those and make the same update. That's what I would probably do.

Posted in Sortable Drag and Drop Discussion

Hey Seph! I did a whole series on it here: https://gorails.com/series/vuejs-trello-clone-in-rails

Hope you enjoy it!
I personally store a local copy of all the information I care about. You can pretty easily sync this information and it's going to make your app a lot quicker not having to hit the API for every page view that needs that information. Stripe doesn't change their data structures very often so you should be fine syncing it. You can also use webhooks to keep it up-to-date.
Hey Victor,

The Carrierwave docs cover this here: https://github.com/carrierwaveuploader/carrierwave/wiki/how-to:-do-conditional-processing

You just want to check if it's an image before running the resizing and it's pretty easy to do. 👍

Posted in Single Responsibility Principle Discussion

Thanks Ron!

Posted in Single Responsibility Principle Discussion

We will finally be diving into testing this year soon. 🤓

Posted in Improving In-App Notifications Discussion

Hey Thato,

You can simply just call that function on the turbolinks:load event (or DOMContentLoaded if you aren't using Turbolinks).

It's as simple as doing something like this:

document.addEventListener("turbolinks:load", function() {
getNewNotification()

})