Room 208

Elaborate Burn

Posts from #rubyonrails

And we can even add weird things like Array#forty_two. You cannot read the comment here, but it says, ‘Equal to self[41]. Also known as accessing “the reddit”.’ This sort of came out of a thread on reddit where somebody was complaining so loudly – why we would care to add second and third and fourth to Array. ‘This is redundant! There’s already a mathematical approach to doing the same thing!’ It doesn’t make sense to them. It was weird. Like, why would somebody care about this level of aesthetics? And just to spite them, I added forty_two.

David Heinemeier Hansson, creator of Ruby on Rails, on why it monkey-patches the Ruby Array class to provide a forty_two method

Phusion Passenger and nginx location blocks

I spent much of yesterday getting Danbooru set up for the new Room 208 imageboard, and one issue in particular wasted a lot of my time. I had nginx configured to serve requests to the Danbooru directory through Phusion Passenger, using the passenger_base_uri directive. No matter what combination of settings I tried, however, Passenger invariably refused to start up. This in turn meant that requests bounced into the application’s public/ directory, leaving me with a 403 when I tried to access the board’s index page.

Now, I’d read somewhere that if a server has a location / block, the passenger_enabled directive has to go inside of it, instead of server:

# Doesn't work
server {
    # ...
    root /my/www/dir;
    passenger_base_uri /booru;
    location / {
        passenger_enabled on;
    }
}

Problem was, of course, that this piece of advice didn’t help, because I had no such block for that server. It turns out, though, that if a directory specified in passenger_base_uri has a corresponding location block, passenger_enabled must be specified there:

server {
    # ...
    root /my/www/dir;
    passenger_base_uri /booru;
    location /booru/ {  # note path change
        passenger_enabled on;
    }
}

In short, if you have a location block corresponding to the root URL of a Passenger application, passenger_enabled belongs inside it. Hope this keeps at least one other person from self-harm.1

  1. No, I didn’t really.