Chris Oliver

Joined

290,710 Experience
86 Lessons Completed
298 Questions Solved

Activity

Posted in Subscriptions with Stripe Discussion

Well if you've got the subscription ID, you can then look up the active subscription and modify the plan just like you would when a user edits their plan.

Oh really good topic! I usually try to avoid it as much as I can, but there's always uses for it because you'll never be able to fully express SQL with an ORM.

I was just reading this post on doing trending posts in Postgres and it was one of those great places where you'd want to drop down to raw SQL to create those functions and things that you could reference later with ActiveRecord: http://sorentwo.com/2013/12...

I'll have to definitely do a screencast on this.

Posted in Subscriptions with Stripe Discussion

You can fail early server side if there's a subscription ID on the user so you can hopefully avoid double charging them. I believe stripe does allow you to have multiple subscriptions per user, so you may not want to rely on that.

If you want to use an external JS file you can just include the script tag that points to it in your layout.

The reason why you would want these inside your Rails app is that they can be included and minified inside your code reducing the number of files the browser has to download. It's faster and more efficient for your users which makes it a good idea.

Posted in File Uploads with Refile Discussion

Hmm, sounds like you've got everything correct! I have used the exact same setup before and it works fine. I'll have to think on it and see what comes to mind.

Posted in File Uploads with Refile Discussion

It's possible that Refile just isn't able to find the executable for imagemagick. It's looking for the "identify" command so you'll want to make sure that's in one of the folders in the PATH for the same user that Nginx is running as. I'd poke around at that and see if you can figure out why it might not be able to find the identify executable. If you installed imagemagick with apt-get then it should be available, but if you compiled it or something else, then it's probably just not in the PATH.

Since Searchkick is a whole separate process, it won't know about your Rails stuff. What I would say is if you write a helper method or class you can have it apply that scope to the options you pass in so that it always searches the same default scope.

Posted in A series on Turbolinks 5

Marek, this would be a killer series to make. I would love to do it. So far, I've been using Turbolinks 5 for a few things but of course have also gotten caught by some of the gotchas so I still need to figure out some solutions to various things so I have a good idea of what all the gotchas are and what decent solutions should be.

Maybe we can use this thread to start keeping a list of topics to cover!

To start:
One of my biggest issues with Turbolinks has been that Chrome doesn't respect clearing the cache on a login of a page. So GoRails for example, I used to use root as the homepage, you would login, and I would replace root's contents with your dashboard. Chrome has a bug in it where it doesn't clear the cache for root until you do an actual browser refresh. The solution I had was to move your dashboard to /dashboard to avoid the cache problems there.

Posted in Group Chat with ActionCable: Part 3 Discussion

I'm not sure I would use ActionCable for uploading files. I would probably just send them like normal using AJAX.

Posted in Migrate away from Mandrill?

Hey Mel! Just recorded this and wanted to share it with ya so you could watch it before I officially publish it. https://excid3.wistia.com/medias/9bst8e6py7

Let me know if this helps! I tried to explain all the aspects of SMTP and stuff to hopefully give a deeper explanation of all the things going on for it, so hopefully it makes things easier to understand!

Posted in Migrate away from Mandrill?

Hey Mel, I've got a project that I need to add Sendgrid to today, so I'm going to make a video on it for you. :)

I think one thing you ran into was that there are a couple ways to talk to Sendgrid. One is the SMTP connection which was what I linked (and the one you'll actually want to use) but then there's the sendgrid API which is not what you want to use, but that's where the gems come from. Two separate things that are never clearly explained the differences about.

I'll be doing a video on SMTP and I'll go into depth to explain how that all works for ya.

Posted in Episodes Source Code

Unfortunately for a lot of the earlier episodes I don't have the source code anymore because they were on my old laptop. :( Anything that does have code up there right now is what I've got.

Posted in Exporting Records To CSV Discussion

What a familiar face. 👋

Good catch, I hadn't run into that but I could see that happening somehow.

Posted in Multi select form & DB search

Hey Sacha,

For those, you actually want to querying using IN so that SQL can look for matches in an array of IDs. For example:

brand_ids = [1,2,3] # These IDs may come from your form params from a multi-select
Order.where(brand_id: brands)
# SELECT "orders".* FROM "orders" WHERE "orders"."brand_id" IN (1, 2, 3)

And remember you can chain your where calls to make it cleaner:

Order.where("created_at between (?) and (?)", self.start, self.end).where(brand: self.brand,  team: self.team)

That'd do it, glad you got it fixed. 🙌

Hey Drazen,

Handful of different ways to do this. If you know which channels the user is joined to server-side, you can just loop through them and then stream_from for each channel. That will setup several redis pubsub connections so you will receive all the messages across those channels.

Posted in Refile uploading via rails console

I'm not entirely sure on that one. I imagine you could write the same value in and then save without callbacks in your seeds in order to populate but not trigger Refile to do a reupload?

Posted in Refile uploading via rails console

Ah ha! I was going to suggest that because I couldn't imagine why everything else was working just fine. Hate when things fail silently like that.

Posted in Multitenancy with the Apartment gem Discussion

You'll want to modify your authentication code to lookup the current tenant and then scope the User lookup query to only ones for that domain that way only users of that tenant can access that tenant.

Posted in Refile uploading via rails console

Are there errors on the page model after save? If you load it fresh out of the database, does the image attribute exist?