Skip to content
Browse files

use alias_method_chain so it plays nicely with other gems that overri…

…de render
  • Loading branch information...
1 parent ae0d891 commit 11757398a6b46c052a9da0bf3d6dbed6d53a20c5 @ghiculescu ghiculescu committed Aug 12, 2013
Showing with 13 additions and 4 deletions.
  1. +13 −4 lib/flash_render.rb
View
17 lib/flash_render.rb
@@ -1,6 +1,16 @@
module FlashRender
-
- def render(*args)
+
+ def self.included(base)
+ # Protect from trying to augment modules that appear
+ # as the result of adding other gems.
+ return if base != ActionController::Base
+
+ base.class_eval do
+ alias_method_chain :render, :flash
+ end
+ end
+
+ def render_with_flash(*args)
options = args.extract_options!
if alert = options.delete(:alert)
@@ -18,9 +28,8 @@ def render(*args)
end
args << options
- super(*args)
+ render_without_flash(*args)
end
-
end
if defined?(Rails::Railtie)

0 comments on commit 1175739

Please sign in to comment.
Something went wrong with that request. Please try again.