Ruby on Rails Extending rails.vim Navigation Commands with projectionist.vim One of my favorite Vim plugins is rails.vim by Tim Pope. And the reason it's one of my favorite Vim plugins is all of the navigation commands that it gives you for working with Ruby on Rails projects. So, rather than having to
Ruby Using the PTY Class to Test Interactive CLI Apps in Ruby I recently created a command line Reverse Polish notation calculator as a programming exercise. It's interactive, so a user runs the executable and then they are presented with a REPL that they can use to evaluate Reverse Polish notation expressions. When the user is
Ruby on Rails Webcal Links in Rails with the icalendar Gem The icalendar gem is a useful way to generate iCalendar files for use with various calendar applications. One thing I couldn't find good documentation on, though, is how to use it to create a Webcal link in a Ruby on Rails app, so I
Ruby on Rails Greatest-Per-Group Query in Rails Using a View Backed Model This is part 4 of 4 in a series on how to use Greatest Per Group queries in Ruby on Rails to avoid the N + 1 query problem: When and how to use Greatest Per Group queries (with PostgreSQL) Rails implementation using custom query
Ruby on Rails Greatest-Per-Group Query in Rails Using a Scoped has_one Assocation This is part 3 of 4 in a series on how to use Greatest Per Group queries in Ruby on Rails to avoid the N + 1 query problem: When and how to use Greatest Per Group queries (with PostgreSQL) Rails implementation using custom query
Ruby on Rails Greatest-Per-Group Query in Rails Using Custom Query Methods This is part 2 of 4 in a series on how to use Greatest Per Group queries in Ruby on Rails to avoid the N + 1 query problem: When and how to use Greatest Per Group queries (with PostgreSQL) Rails implementation using custom query
Ruby on Rails Greatest-Per-Group Query in PostgreSQL Using DISTINCT ON This is part 1 of 4 in a series on how to use Greatest Per Group queries in Ruby on Rails to avoid the N + 1 query problem: When and how to use Greatest Per Group queries (with PostgreSQL) Rails implementation using custom query
How I Record Programming Talks I usually record the talks at the Portland Ruby Brigade's monthly meetings. In part this is because it feels like a shame to have the knowledge contained in the talks not be available to the wider world. But also it's because it's just not
Ruby on Rails Rails: Static Pages Using the Controller Route Macro One of my Rails apps recently took responsibility for serving the home page and marketing pages from an installation of Wordpress, mainly to allow for a site-wide nav bar which shows login status. Doing this in Rails is not rocket science, but after experimenting
Ruby on Rails Rails: Organizing Controllers with Modules One of my Ruby on Rails apps has lots of models and a few models that each have lots of has_many associations. For instance, the Company model has 27 has_many associations. Naturally, I have routes and controllers for most of these associations,
Ruby on Rails Rails: Organizing Models by Attribute One of the Ruby on Rails apps that I work on has a few models that have lots of stuff in them. The Company model in this app is 311 lines long. Now, I know that won't break any records – theUser model in Discourse
Ruby on Rails Rails: Testing for Insecure Admin Routes I have a Ruby on Rails app with an admin section, as is common for a lot of apps. The admin section is namespaced, so all of the controllers are named something like Admin::WidgetsController and the routes all start with /admin. Now, there
Ruby on Rails Rails: Testing for Orphaned Routes Over time, one of my large Ruby on Rails apps has accumulated a lot of cruft in it's routes file. In addition to the normal entropy that accumulates in any large app, I didn't really have a solid grasp of how routes worked when
Leveling Up Revisited I previously wrote about leveling up as a programmer. At the time, I had forked a list of programming achievements originally belonging to Jason Rudolph and left his list mostly intact. That was a mistake on my part. Most of his achievements are pretty
Leveling Up I recently read a blog post by Jason Rudolph about leveling up as a software developer. To paraphrase him, the idea is to: Identify the experiences that advance a person as a developer. Select a particular experience to pursue. Pursue that experience to completion.
Ruby on Rails Rails: Is the Attribute Actually Optional? Ruby on Rails model attributes are optional by default. That is, unless you specify otherwise, an attribute is not required for a model instance to be valid. I like to test that this is, in fact, the case. test "weight is not required&
Ruby on Rails Rails: Are the Fixtures Valid? A common pattern in my Ruby on Rails unit tests is to start with a valid instance of a model, make a change to the attribute I'm testing, then assert that the model instance is no longer valid. test "weight is required"
Returning to Computation Way back in the day, when I was in college, I took a class on basic programming with C++. I only did okay in that class, but the concepts really stuck. There was something about decomposing work into it's fundamental units -- variables, conditionals