Trevor Owens

Joined

2,870 Experience
19 Lessons Completed
1 Question Solved

Activity

OK, I figured out what I did wrong.

I thought this was able to work with the Rails Asset Pipeline, but now I realize it does not.

Installing Tailwind CSS sets it up in the javascript/css directory which is where PurgeCSS gets it from.

Since I'm not a fan of Tailwind (don't like having loads of CSS classes attached to my divs) and prefer Bootstrap, I was hoping this would also work with the Bootstrap gem. I see that it needs some extra config to load Bootstrap through the Webpacker CSS pipeline.

That's what I tried and can't get it to work. Does Rails first render the .haml into HTML and then PurgeCSS reads it or does PurgeCSS have ability to read HAML and ERB?

How does this work with .haml templates instead of .erb?

This is a great video.

Is it possible to remove jQuery if you are using Bootstrap 4? I know it's a dependency but maybe if you are not using all aspects of Bootstrap you can remove it.

Anyway, removing jQuery is a good way to remove 250kb (30kb gzipped) from your website's download which is not bad at all.

Or even better if it's on Hatchbox!

Great tutorial, but I am missing something... What is the benefit of using Hatchbox over Heroku?

Posted in Doorkeeper Omniauth OAuth Client Discussion

Thanks Chris, I fixed it. The problem was my me.json.jbuilder file was in the wrong directory. :)

Would have corrected this last night, but my comment didn't show up.

Posted in Doorkeeper Omniauth OAuth Client Discussion

Comments are not working for me! :(

Posted in Doorkeeper Omniauth OAuth Client Discussion

Hello, after I click "Authorize" it never makes it to the byebug and I get the following error:

undefined method `[]' for nil:NilClass

uid { raw_info["id"] }

This happens inside the doorkept-client app and is referring to the omniauth-doorkept gem we made, specifically the file doorkept.rb on line 16.

Posted in Doorkeeper Omniauth OAuth Client Discussion

After I click "Authorize" it never makes it to the byebug and I get the following error:

undefined method `[]' for nil:NilClass

uid { raw_info["id"] }

Posted in Doorkeeper Omniauth OAuth Client Discussion

After I click "Authorize" it never makes it to the byebug. I get an error that says:

undefined method `[]' for nil:NilClass

uid { raw_info["id"] }

The error is inside "doorkept-client"

It is referring to the omniauth-doorkept gem inside the file doorkept.rb on line 16

Posted in Conflict between Chartkick gem and Trix Editor

Fixed this myself.

There was no conflict between the two gems, I had a syntax error in my JS where I made the ajax call.

Posted in Conflict between Chartkick gem and Trix Editor

I'm getting an error on pages that use chartkick (both highcharts and chart.js) due to the Trix Editor. Everything works fine but the error being thrown concerns me.

Anyone have thoughts?

Error with Chart.js

Uncaught DOMException: Failed to execute 'registerElement' on 'Document': Registration failed for type 'trix-toolbar'. A type with that name is already registered.
    at Object.e.registerElement (eval at <anonymous> (eval at <anonymous> (http://localhost:3000/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350:22)), <anonymous>:16:26500)
    at eval (eval at <anonymous> (eval at <anonymous> (http://localhost:3000/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350:22)), <anonymous>:17:9896)
    at eval (eval at <anonymous> (eval at <anonymous> (http://localhost:3000/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350:22)), <anonymous>:17:10290)
    at eval (eval at <anonymous> (eval at <anonymous> (http://localhost:3000/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350:22)), <anonymous>:22:2244)
    at eval (eval at <anonymous> (eval at <anonymous> (http://localhost:3000/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350:22)), <anonymous>:22:2362)
    at eval (<anonymous>)
    at eval (eval at <anonymous> (http://localhost:3000/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350:22), <anonymous>:350:22)
    at Function.globalEval (eval at <anonymous> (http://localhost:3000/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350:22), <anonymous>:351:7)
    at text script (eval at <anonymous> (http://localhost:3000/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350:22), <anonymous>:10373:11)
    at ajaxConvert (eval at <anonymous> (http://localhost:3000/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350:22), <anonymous>:9333:18)

Error with Highcharts.js

Uncaught Error: Highcharts error #16: www.highcharts.com/errors/16
    at Object.a.error (highcharts.self-2d5d4b77c48d035111dc8833f1f00e209e9acfb2956499a10ab4487a04bb2883.js?body=1:11)
    at eval (eval at <anonymous> (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350), <anonymous>:10:38)
    at eval (eval at <anonymous> (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350), <anonymous>:11:12)
    at eval (eval at <anonymous> (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350), <anonymous>:9:103)
    at eval (eval at <anonymous> (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350), <anonymous>:9:109)
    at eval (<anonymous>)
    at jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:350
    at Function.globalEval (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:351)
    at text script (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:10373)
    at ajaxConvert (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:9333)

Initially the Trix Editor wouldn't load at all, but then I put trix.js on a lower line than chartkick and highcharts/chart.js in my application.js and now the Trix Editor loads fine and so do the charts but it throws this error.

Posted in Gravatar blocked in China, need a workaround

Gravatar is blocked in China where we have a ton of users. Which means if you pull gravatar from their site in your app, your website will crash/not load for anyone based in China.

So I have two options:

  1. Upload all gravatars to s3 with workers and serve them ourselves
  2. Figure out a workaround

Workaround #1 is to use a CDN like cloudflare that I can use to serve Gravatars. It would be great if something like this existed that was plug and play, it would also improve performance.

Workaround #2 is to pull from the Chinese gravatar mirror for anyone who is within China based on their IP address.

Workaround #3 is to cache the images with Gravatar Ultimate gem which uses ActiveSupport::Cache::SynchronizedMemoryStore.new (https://github.com/sinisterchipmunk/gravatar). I'm not sure if this is scalable for tens of thousands of daily users.

Workaround #4 is to detect the failure from Gravatar somehow in the browser and if it fails to display the default (non-image based) avatar. Would be great if it did this for all avatars after the first try or remembered and remembered on subsequent attempts.

Perhaps the fourth is the easiest/most robust, but I'm not sure how to do it. For gravatars, I've always used this simple helper method:

def gravatar_url(user)
    gravatar_id = Digest::MD5.hexdigest(user.email.downcase)
    "http://gravatar.com/avatar/#{gravatar_id}.png?d=identicon&s=150"
end

I've heard about ES6 recently but I'm a little confused.

What is ES6 and what is the benefit of using it in Rails?