Created
          November 8, 2010 23:23 
        
      - 
      
- 
        Save sdhull/668461 to your computer and use it in GitHub Desktop. 
    the problem
  
        
  
    
      This file contains hidden or 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 ViewContext | |
| def initialize(*args) | |
| @_content_for = Hash.new | |
| end | |
| def content_for(name, content, &block) | |
| content = capture(&block) if block_given? | |
| @_content_for[name] = content | |
| end | |
| end | |
| class ActionController::Base | |
| def view_context | |
| ViewContext.new | |
| end | |
| end | |
| ##### | |
| @controller = ActionController::Base.new | |
| @controller.view_context.content_for :foo, :bar | |
| @controller.view_context.instance_variable_get "@_content_for" # => {} | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment