acts_as_rickroll

In the spirit of the day I’ve released acts_as_rickroll. Instead of pranking you, I’m releasing a tool for Rails developers to prank other people. If you want to try this out, download the acts_as_rickroll plugin and expand it in your vendor/plugins directory.

This plugin overrides the redirect_to method of ActionController so that if you pass in a specific :id to the redirect_to method, the recipient will get rickrolled. Once you have installed the plugin you can add acts_as_rickroll ‘foo’ to your controller. Now if you ever call redirect_to :id => ‘foo’ they will be redirected to to a rick roll instead.

The idea behind this plugin is that you can use this on an existing controller that already happens to use redirect_to. Here is a simple example from one of my controllers:

class MyController < ApplicationController
  acts_as_rickroll 'rick'

  def index
    number = rand(100)

    if (number % 5) == 0
      redirect_to :action => 'most_recent'
    else
      redirect_to :id => 'rick'
    end
  end
end

Comments are closed.