Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 1170

Show
Ignore:
Timestamp:
04/16/05 16:08:29 (4 years ago)
Author:
david
Message:

Changed render_partial to take local assigns as the second parameter instead of an explicit object and then the assigns

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r1160 r1170  
    11*SVN* 
     2 
     3* Changed render_partial to take local assigns as the second parameter instead of an explicit object and then the assigns. So the API changes from: 
     4 
     5    <%= render_partial "account", person, "rules" => regulations.rules %> 
     6     
     7  ...to: 
     8   
     9    <%= render_partial "account", :account => person, :rules => regulations.rules %> 
     10   
     11  The old API will still work, though, and render_partial "account" will still assume :account => @account. 
    212 
    313* Added submit_to_remote that allows you to trigger an Ajax form submition at the click of the submission button, which allows for multiple targets in a single form through the use of multiple submit buttons #930 [yrashk@gmail.com] 
  • trunk/actionpack/lib/action_controller/base.rb

    r1130 r1170  
    243243 
    244244    # Holds the request object that's primarily used to get environment variables through access like 
    245     # <tt>@request.env["REQUEST_URI"]</tt>. 
     245    # <tt>request.env["REQUEST_URI"]</tt>. 
    246246    attr_accessor :request 
    247247     
     
    251251     
    252252    # Holds the response object that's primarily used to set additional HTTP headers through access like  
    253     # <tt>@response.headers["Cache-Control"] = "no-cache"</tt>. Can also be used to access the final body HTML after a template 
    254     # has been rendered through @response.body -- useful for <tt>after_filter</tt>s that wants to manipulate the output, 
     253    # <tt>response.headers["Cache-Control"] = "no-cache"</tt>. Can also be used to access the final body HTML after a template 
     254    # has been rendered through response.body -- useful for <tt>after_filter</tt>s that wants to manipulate the output, 
    255255    # such as a OutputCompressionFilter. 
    256256    attr_accessor :response 
    257257     
    258     # Holds a hash of objects in the session. Accessed like <tt>@session["person"]</tt> to get the object tied to the "person" 
     258    # Holds a hash of objects in the session. Accessed like <tt>session[:person]</tt> to get the object tied to the "person" 
    259259    # key. The session will hold any type of object as values, but the key should be a string. 
    260260    attr_accessor :session 
    261261     
    262     # Holds a hash of header names and values. Accessed like <tt>@headers["Cache-Control"]</tt> to get the value of the Cache-Control 
     262    # Holds a hash of header names and values. Accessed like <tt>headers["Cache-Control"]</tt> to get the value of the Cache-Control 
    263263    # directive. Values should always be specified as strings. 
    264264    attr_accessor :headers 
  • trunk/actionpack/lib/action_view/partials.rb

    r1169 r1170  
    22  # There's also a convenience method for rendering sub templates within the current controller that depends on a single object  
    33  # (we call this kind of sub templates for partials). It relies on the fact that partials should follow the naming convention of being  
    4   # prefixed with an underscore -- as to separate them from regular templates that could be rendered on their own. In the template for  
    5   # Advertiser#buy, we could have: 
     4  # prefixed with an underscore -- as to separate them from regular templates that could be rendered on their own.  
     5  # 
     6  # In a template for Advertiser#account: 
     7  # 
     8  #  <%= render_partial "account" %> 
     9  # 
     10  # This would render "advertiser/_account.rhtml" and pass the instance variable @account in as a local variable +account+ to  
     11  # the template for display. 
     12  # 
     13  # In another template for Advertiser#buy, we could have: 
     14  # 
     15  #   <%= render_partial "account", :account => @buyer %> 
    616  # 
    717  #   <% for ad in @advertisements %> 
    8   #     <%= render_partial "ad", ad %> 
     18  #     <%= render_partial "ad", :ad => ad %> 
    919  #   <% end %> 
    1020  # 
    11   # This would render "advertiser/_ad.rhtml" and pass the local variable +ad+ to the template for display. 
     21  # This would first render "advertiser/_account.rhtml" with @buyer passed in as the local variable +account+, then render  
     22  # "advertiser/_ad.rhtml" and pass the local variable +ad+ to the template for display. 
    1223  # 
    1324  # == Rendering a collection of partials 
     
    2839  # Two controllers can share a set of partials and render them like this: 
    2940  # 
    30   #   <%= render_partial "advertisement/ad", ad %> 
     41  #   <%= render_partial "advertisement/ad", :ad => @advertisement %> 
    3142  # 
    3243  # This will render the partial "advertisement/_ad.rhtml" regardless of which controller this is being called from.