Nested layouts in Rails aren’t a technique that I’ve had to use a lot in the past, but I’m finding myself using them quite a bit in my current work. Nesting layouts allows for some sharing of a common view structure. The best example of this that I have come across is in the app I am working on. This...
My normal Rails 5.x development stack now uses Chrome, running headlessly, powered by the following gems: # Gemfile # ... gem 'capybara' gem 'chromedriver-helper' gem 'capybara-selenium' Unlike using things like Poltergeist, the only external dependency you need to run these tests is Chrome itself. If you wish to reduce your gem dependencies, you can also remove chromedriver-helper, but this will...
The @at-root directive can be quite useful for creating SASS rules where you need to jump outside of a SASS scoping block back to the root level when your styles are compiled. In particular, this directive can be useful for generating BEM styles, since the & abbreviation continues to work for targeting the parent selector. Here’s an example of a...
While working on a feature test today, I learned that any database data that is modified in a before(:all) callback in an RSpec test is retained outside of the test run. This is documented quite clearly in the RSpec documentation, I just haven’t had the opportunity to work with these types of callbacks regularly before. The test I ran into...
TIL about the CSS property text-underline-position. This property is a useful progressive enhancement to achieve a particular look and feel for links, in particular for content with many descenders. Examples: This is standard underlined text. This text has the underline position set to "under". This text has a bottom border instead of an underline. Notice that the border overflows the...
Today I learned about a CSS selector I have not used a great deal before - pipe-equals. The spec describes this operator as: Represents an element with the att attribute, its value either being exactly “val” or beginning with “val” immediately followed by “-“ This selector is particularly useful for loose matching of BEM CSS classes, and other dasherized class...
I’ve used Calibre for years to manage my eBook collection. It’s a great piece of software that has always worked really well for me. I discovered today that Calibre has the ability to start a “content server”. This provides an endpoint which serves information about the Calibre library, including covers, titles, and descriptions. The content server can be started by...
Sometimes an application can have pretty complex configuration for certain components. There’s always temptation to put these settings straight in your service, but today I learned about a simple method built into Rails from 4.2 onwards that lets this config live outside of your Ruby classses: Rails.application.config_for. This method allows you to place your config in an environment-namespaced YAML file...
I often struggle with the correct way to set any kind of configuration on a class, especially when it is a class intended to integrate with an external API that usually needs several configuration values. I initially implemented my own configuration pattern, before coming across this great pattern by ThoughtBot that has been used for their open-source library Clearance: class...
I frequently find myself tramping into the Tararua Forest Park from the Mount Holdsworth road-end, travelling through Donnelly Flat, a popular picnic spot around 10 minutes from the roadend. After considering the lack of signed history regarding the history of the Flat, and after being unable to find out any information from Archives, National Library, Papers Past or regional libraries,...