-
Safely Accessing Values from Nested Hashes (again)
Implementing a companion method to
Continue reading …Hash#dig
that always returns a value and never throws an error and allows for a default return value. -
Basic RESTful Filtering with Rails
Filtering a collection of data objects into a subset is one of the most common tasks in data-management applications. While well-tread, this problem space provides rich opportunity for exploring and learning about how to implement RESTful, maintainable, flexible, and robust Rails applications. In this post I want to implement a simple filtering feature, walking through the various aspects at the model, controller, and view layers.
Continue reading … -
An interlude with minitest/autorun
An interlude in a series of posts laying out the process, step by step, of building an interpreter in Ruby for working with propositional logic. In this small post, we take our hand-rolled "tests" and move the code into an executable test script with
Continue reading …minitest/autorun
. -
Proper Propositional Logic
The second in a series of posts laying out the process, step by step, of building an interpreter in Ruby for working with propositional logic. In this second post, we expand the interpreter to handle the full range of valid expressions in classical propositional logic.
Continue reading … -
Starting Simple
The first in a series of posts laying out the process, step by step, of building an interpreter in Ruby for working with propositional logic. In this first post, we build an interpreter for working with simple logical expressions and dig into the specifics of the parts of an interpreter as well as the basics of propositional logic.
Continue reading … -
Time in Ruby and ActiveRecord
How does the Ruby
Continue reading …Time
class relate to the ActiveRecordtime
column type? -
Typecasting in Ruby and Rails
I recently had the need to typecast string values passed as query parameters to a controller action to their appropriate type. In solving this problem, I've learned a lot about Rails' typecasting layer, Ruby's typecasting methods, as well as a handful of edge cases. The result was a typecasting function that I think has a lot to offer.
Continue reading … -
A Simple Tree Building Algorithm
It is, unfortunately, not that often that I get the opportunity to devise an algorithm to solve a problem at work. Most work simply doesn’t require that kind of thinking. But I thoroughly enjoy that kind of thinking, and thus thoroughly enjoyed the most recent opportunity I had to employ it. The problem was simple (though I have simplified and abstracted it for this post as well): we have a database table of
Continue reading …things
, and thesethings
have a parent-child hierarchy, and we need to display a tree of thesethings
in our UI. So, let’s dig in. -
An Example of an ERB Component
An example of building an "ERB component", that is, an ERB partial that has ansome flexibility around their HTML output articulated via an interface in the
Continue reading …render
call. -
A function for generating HTML attribute values
How might I write a function that was as flexible as possible in its type signature, and yet still predictable and sane in its output of HTML attribute values?
Continue reading …