Created
June 6, 2011 04:29
-
-
Save nthj/1009747 to your computer and use it in GitHub Desktop.
Add Rails Controller filters aliases, like after_show, before_destroy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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