Mark Grealish

the life and code of a crazy cat man


Oh, Cookie

in animals

“No Cookie! Feet are friends, not food! Feet are not for teeth!”

Sullen Cookie loaf

Add sub-controller modules to Rails 5 routing concerns

in code

Routing concerns have been a thing since Rails 4, but this morning I ran into a real annoyance: the documentation doesn’t adequately explain how to pass a module, in cases where you use separate sub-controllers. More than that, even-what if I want to pass any other options?

Here’s what I came up with, using splats and blocks:

concern :likeable do |options|
  resource :like, only: [:create, :destroy], **options
end

resources :posts do
  concerns :likeable, module: :posts
end

resources :comments do
  concerns :likeable, module: :comments
end

The output routes appear thus:

comment_like DELETE   /comments/:comment_id/like(.:format)    comments/likes#destroy
             POST     /comments/:comment_id/like(.:format)    comments/likes#create
...
   post_like DELETE   /posts/:post_id/like(.:format)          posts/likes#destroy
             POST     /posts/:post_id/like(.:format)          posts/likes#create

Simple and dumb MOC theme

in code

MOC <3

background              = white    default
current_time            = white    default    bold
directory               = white    default
disabled                = white    default
empty_mixer_bar         = white    default
empty_time_bar          = white    default
enabled                 = white    default    bold
entry                   = white    default
entry_title             = white    default
error                   = white    default    bold,underline
file                    = white    default
filled_mixer_bar        = white    default    reverse
filled_time_bar         = white    default    reverse
frame                   = white    default
info                    = white    default    underline
legend                  = white    default
marked_file             = white    default    bold
marked_selected_file    = white    default    bold,underline
message                 = white    default
playlist                = white    default
plist_time              = white    default
selected_directory      = white    default    reverse
selected_file           = white    default    reverse
selected_playlist       = white    default    reverse
sound_parameters        = white    default    bold
state                   = white    default
status                  = white    default
time_left               = white    default    bold
time_total_frames       = white    default
title                   = white    default    bold
total_time              = white    default    bold
window_title            = white    default

Hear me roar!

in animals

Cookie roars

The hard life of a vim multitasker

in technology

No respite.

Everywhere, vim

The grimmest grim view that ever grimmed a grim

in ireland

Taken from the shore at Blackrock.

Looking toward Poolbeg from Blackrock