Chris Oliver

Joined

292,890 Experience
93 Lessons Completed
295 Questions Solved

Activity

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()

})

Posted in The Params Hash Discussion

πŸ™ŒLet me know if there are any other basics you'd like me to cover in-depth like this!
What part of the blogs needs to be realtime?

Posted in Devise Secret Key was not set automatically

So your RAILS_MASTER_KEY is an environment variable you add to the Heroku admin in the Environment Variables section. You don't ever want that in your repository.

The secret_key line needs to go in your initializer replacing the one you manually added.

Posted in Devise Secret Key was not set automatically

In Rails 5.2, you have the new credentials file and you must set your credentials secret_key_base to the Devise secret key.


config.secret_key = Rails.application.credentials.secret_key_base

You'll need to put your RAILS_MASTER_KEY env variable in as well so your app can decrypt the credentials file.

I'm guessing they'll fix this in a new release soon, but for now this is the solution I used. πŸ‘

Posted in Render partial via AJAX without JQuery

Yep, the Rails forms use Rails.ajax automatically now and you can also trigger it manually if you want like if you were trying to build infinite scroll pagination for example.

Posted in Rails Application Templates Discussion

Hey Gustavo,

Sounds like your Redis instance on Heroku has a maximum number of connections. You might need to reduce the concurrency on Sidekiq or something to create less Redis connections (or increase your Redis node).

Posted in Render partial via AJAX without JQuery

In that case, I would highly recommend checking out Stimulus JS. Rails has the Rails.ajax helper method to handle AJAX, and you can insert the results in to the page like you're doing. Then Stimulus can handle any interactivity you might want with it. It's about the simplest way of building interactive things I've used. You'll like it!