rails
Showing users friendly errors when using Liquid templating in Rails
Fri, May 7, 2021 - ~800 Words
When allowing users to work with templates in your system, e.g. for a CRM where you might want email templates, Liquid is a very widely-used option. If it has worked for Shopify all this time then there’s a good chance it will work for our users.
In this post I’ll touch on how to use Liquid in your Rails application, but the main problem solved here is how to make the template syntax error messages friendlier for your users.
Zero Downtime Migrations With Rails and Mysql 5.6+
Sat, Apr 18, 2020 - ~700 Words
As the size of your tables increases the risk of downtime also increases as MySQL will by default apply a full table lock for many typical DDL operations.
If you find yourself in the position where adding a column to a table will cause downtime for your application then you may avoid transformation of your schema in general, which can stop a major part of the system design from evolving.
Setting Up React and Bootstrap 4 on Rails 6
Sun, Sep 8, 2019 - ~800 Words
In this post we will take a freshly-created Rails 6 app and set up React with Bootstrap 4 such that both the Rails and React-based views can use Bootstrap components.
Simpler Handling of AJAX Form Errors in Rails 4
Thu, Aug 18, 2016 - ~1500 Words
The Problem With unobtrusive Javascript, converting a form in Rails to use AJAX is as easy as setting remote: true:
= form_for Client.new, remote: true do |form| = form.text_field :name This will cause our form to submit asynchronously, and expect a Javascript response, which will be executed directly to e.g. update the page appropriately.
DHH recommends that we design our apps in this manner, where in the Javascript response we re-render the model using its template and use jQuery to update the HTML on the page.
Reinstalling MySQL on OSX using Homebrew
Thu, Jan 28, 2016 - ~300 Words
If you find that you need to have a particular version of MySQL installed on your OSX machine (e.g. to match the version running in production) but you already have a different version of MySQL installed via Homebrew, then the notes below may help you to replace the installed version with the one you need.
DISCLAIMER: The following instructions involve the complete removal of the existing MySQL installation, including any databases.
Robust Integration Testing in Rails 4 with RSpec, Capybara and Selenium
Wed, Aug 20, 2014 - ~2900 Words
The Problem Using RSpec and Capybara to test your Rails apps can make writing tests easier which is good both from a perspective of getting people to actually write tests but also for our general productivity as developers.
While it has its detractors, I like the terse syntax and ease with which we can define our own helpers which help set up certain contexts such as in this case setting up the default account and switching into its subdomain: