Skip to content

Instantly share code, notes, and snippets.

@nthj
Created June 6, 2011 04:29
Show Gist options
  • Save nthj/1009747 to your computer and use it in GitHub Desktop.
Save nthj/1009747 to your computer and use it in GitHub Desktop.
Add Rails Controller filters aliases, like after_show, before_destroy
module Railings
module Filterable
[:after, :before].each do |context|
[:index, :show, :new, :create, :update, :destroy].each do |action|
define_method "#{context}_#{action}", ->(filter, options = { }, &block) do
send "#{context}_filter", filter, options.merge!(:only => action), &block
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment