Toggling TinyMCE v4

Heres a easy way to turn on and off the TinyMCE editor for version 4. document.getElementById('toggle-tinymce').addEventListener('click', function(e) { e.preventDefault(); var editorID = this.dataset.editorId; var editor = tinymce.EditorManager.get(editorID); if (editor) { editor.remove(); } else { editor = tinymce.EditorManager.createEditor(editorID, tinyMCE.settings); editor.render(); } }); You…

shopify_app_whitelist Gem

I regularly use shopify_app. Its a great way to get an app, embedded or not, up and running with Rails. Sometimes I'll create apps with shopify_app which are to be used by only one store. These apps sometimes have a front-end component for the themes... proxy integration, or…

Journey to Sucker Punch

Background jobs are great. Mailing, data processing, image processing, database operations… you name it. If its a repetitive blocking process for the user and its not time-sensitive, then its probably suited to be moved to a job. delayed_job My go-to ActiveJob adapter for Rails has always been Delayed Job.…

Developing sanely on Windows

Preamble You might think, "Why are you trying to develop on Windows? Why not use OSX or (insert Linux distro)". Its because I'm preparing for a stable future. With the decisions of Apple the past year with the iPhone and new Macbook, I no longer like the direction…

Testing with shopify_app

shopify_app is a great Gem to quickly build a Shopify App with Rails. It handles all the verifications, authorizations, webhooking, and more; leaving you to focus on developing your app. This post is to serve as a quick-tip on how to unit-test your app with the Gem. Other than…

Counting Unique Options in Shopify

Ever wanted to quickly display a how many of an option a product contains? Available in 4 sizes ... Available in Red, Blue, Green ... Available in 10 colors Here's an example of how to do just that (for color). Simply open your product's loop liquid and add this block at the…

Precompiling Assets In Your Rails Engine

This'll be a quick post to highlight an issue I had where I needed to precompile an asset file for my Rails engine that was not to be compiled with the other engine assets. Recently, I added TinyMCE-Rails to Guts instead of rolling it in on its own. This allows…

Extending a Rails Engine

Redesigning my CMS in Rails has been great fun. Theres been many challenges faced, and many conquered (like having 100% code coverage :D). One thought that crossed my mind after building the monster was how do you extend an engine? By extending, I mean to add or overwrite methods of…

Polymorphic and Route Concerns... who is who?

The goal of this post is to outline some tips on easily figuring out the parent object for a polymorphic modal/route/controller. Let's start with the basics... Polymorphic For those unfamiliar to it, Polymorphic is an Active Record association type where a model can belong to other models. As…

Calculating Percent Saved with Shopify

Visually displaying to the customer how much they are saving is a big help to driving them towards a purchase. This is a simple snippet and guide to help you achieve this functionality in your Shopify stores. First, to calculate the percentage saved, lets look at the basic math for…