Created
August 2, 2010 01:33
-
-
Save hiroshi/503992 to your computer and use it in GitHub Desktop.
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
class ApplicationController < ActionController::Base | |
# FORCE to implement content_for in controller | |
# I'm not sure that this works with rails < 3.0.0rc | |
def view_context | |
super.tap do |view| | |
(@_content_for || {}).each do |name,content| | |
view.content_for name, content | |
end | |
end | |
end | |
def content_for(name, content) # no blocks allowed | |
@_content_for ||= {} | |
if @_content_for[name].respond_to?(:<<) | |
@_content_for[name] << content | |
else | |
@_content_for[name] = content | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment