Chris Oliver

Joined

292,970 Experience
93 Lessons Completed
295 Questions Solved

Activity

Also if you're using Turbolinks 5 (I've yet to upgrade) then I think it also has the same progress bar.

Hey Enrique! I'm actually just using the stock Turbolinks progress bar that's builtin. I think the only thing you have to do is add a little CSS to make sure that it displays.

https://github.com/turbolinks/turbolinks-classic#progress-bar

Posted in Using Webhooks with Stripe Discussion

Awesome! Also if things get out of sync for some reason and you've got the customer ID, you can generally hit their API and ask for the customer's subscriptions and sync them to your database. That way you won't have to clear your DB or anything. It's that keeping-in-sync process that really would be nice if it was easily automated.

Posted in Using Webhooks with Stripe Discussion

I think Matt's answer is correct. Basically just need to reverse your way back to the code that creates the Subscription object (in your database) and attaches that to the user. Maybe it's not saving?

Posted in best way to validate URL

  1. You'll definitely want to do some parsing and validation. For example, leaving out the protocol happens all the time where someone might type in just gorails.com into the field. The protocol is important, otherwise you can print out a link that ends up being relative on accident like https://gorails.com/example.com. You see this stuff all the time when validations haven't been written properly.

  2. You can use the url input field type to have the browser do a little verification. This will help with the frontend validation since it should require users to type in a protocol like http:// at the beginning. Here's how to use that url field: http://apidock.com/rails/ActionView/Helpers/FormHelper/url_field

  3. Server side, you could simply require all the urls to have http:// or https:// at the beginning. That's nice and simple, can do that with regex or just plain Ruby. Easy to maintain. The Coderwall link Enrique posted is a great example of an implementation like that (although it looks like it has a couple small issues). It basically uses Ruby to parse the URL and verify the protocol. That's important because simple regex checks can't verify the TLD at the end of the domains easily. There are infinite number of TLDs now, and it's going to be best to rely on the Ruby standard library for this because it will always get updated behind the scenes and you have no external dependencies.

  4. Now all these methods: regex, URI, gems, etc are all going to be approximations. If you truly want to make sure the URL is 100% valid, the best way is just to simply make a request server side anytime the URL changes to request the status code for it.

require 'open-uri'
open("https://gorails.com").status
=> ["200", "OK"]

As long as you get a 200 status, then you know the URL is truly valid. You can't do anything more accurate than that, but it's also going to slow down your server response somewhat to request the page. Worth considering how important it is to have 100% correct because you're trading off server time vs correcting a number of errors on user input. It probably depends on how often you see mistyped URLs. You could also make an AJAX endpoint that does this to improve validations client side when the user is typing so it doesn't have to significantly delay server side validations.

I definitely will. I also need to learn some around Swift and Android so that I can make some example apps using the Turbolinks adapters. That might mean we'll have a GoRails mobile app at some point. :)

I've found that using Segment.io for managing those external libraries helps a lot. It makes that management a lot easier, but I also intentionally use very few third-party Javascript libraries because they can quickly slow down the frontend performance of a site. You might check out Segment and see how it goes.

https://segment.com/docs/li...

Hey Pete, this usually happens from one of two things:

1. You're using a third party library (like Segment.io for example) that isn't compatible with Turbolinks events by default. These usually require some tweaking in order to make compatible. It all depends on the library but there are usually ways to do it. You can google for that library + turbolinks and see if anyone else has made it work, or if you can tweak it yourself.

2. Sometimes it can just be a simple setup issue if your JS is running incorrectly. Maybe you need the jQuery.turbolinks adapter, or just to modify your code slightly to allow running on multiple pages.

It all kinda depends on your code and the issues you're experiencing. They can be kinda hard to track down so the easy solution is to turn off turbolinks for those links in the meantime if you can figure it out. I don't think there's anything wrong with that so you can figure it out later.

Heck yeah man! :D

Posted in GoRails speed

It took me a little while, but I did it! https://gorails.com/episodes/gorails-performance?autoplay=1

Good news! Heroku is actually really easy now.

Just tested it this morning and it's super easy to setup: https://github.com/excid3/a...

The trick is that you _must_ use the route mounted version because Heroku apps only expose one port. Just make sure you have a Redis connection added, and you should be all set.

You can try out my example app here: http://actioncable-gorails.... (just make sure you're on http, not https.

I haven't yet, was hoping that the first release candidate would ship, but still waiting on that. I put these episodes out and then like the next week a bunch changed so I didn't want to be making too many immediately outdated episodes.

Posted in GoRails speed

The memoization one is definitely up this alley. One really good example use case (that I realized after recording that episode) was that when you want to sync records from an API, memoizing the results so you can save / update copies in your database is really helpful.

I'm going to do another episode talking about all the things I use on GoRails, but that's definitely one of the tactics.

Posted in Deployment Question

Feel free to post it here so other people can find it and the solution. Which version did you upgrade to? 3.4.0?

Posted in Deployment Question

The Rails version doesn't matter because the error is in Capistrano and there's a missing compatibility thing somewhere internally.

Posted in Deployment Question

You might want to update to the latest Capistrano. https://github.com/capistrano/capistrano/issues/1641

Posted in How to add logo image to mailer

Ah cool. I've used https://github.com/cyu/rack-cors in the past to do that, but then I just started paying $50/yr for Typekit and no longer have to deal with that for almost any fonts I could want to use.

Posted in How to add logo image to mailer

Oh fun, CORS is not a super fun thing to mess with. I'm not sure if you can do that with email, but you have to allow origins with CORS to determine where your fonts can be loaded from: http://stackoverflow.com/questions/27726802/css-font-being-blocked-from-cross-origin-resource-sharing-policy

Posted in How to add logo image to mailer

You should just be able to use the regular old <%= image_tag("logo.png") %> helpers just like you would use in your views. You may need to set your asset_host so that it includes a full URL for the images in the emails since they aren't displayed in the browser under your domain.

# I believe these should do the trick:
config.action_controller.asset_host = 'http://localhost:3000'
config.action_mailer.asset_host = config.action_controller.asset_host

This looks like a fun project! If you've already got elasticsearch going, it'll do really well to handle the search queries (plus it should handle the ordering from closes to furthest as well). Curious to hear how it goes man!