Skip to content

Instantly share code, notes, and snippets.

@hiroshi
Created August 2, 2010 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiroshi/503992 to your computer and use it in GitHub Desktop.
Save hiroshi/503992 to your computer and use it in GitHub Desktop.
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