aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-16 16:08:29 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-16 16:08:29 +0000
commit6ee06ebec6814576b16f6438c89fb53d557305c2 (patch)
tree8119a05e75fa1b86485d05debeb0606970dadb93 /actionpack
parent82456d9392e4abc0a402294c32089b646975eed4 (diff)
downloadrails-6ee06ebec6814576b16f6438c89fb53d557305c2.tar.gz
rails-6ee06ebec6814576b16f6438c89fb53d557305c2.tar.bz2
rails-6ee06ebec6814576b16f6438c89fb53d557305c2.zip
Changed render_partial to take local assigns as the second parameter instead of an explicit object and then the assigns
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1170 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG10
-rwxr-xr-xactionpack/lib/action_controller/base.rb10
-rw-r--r--actionpack/lib/action_view/partials.rb21
3 files changed, 31 insertions, 10 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index dd80def3ac..0687be4698 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,15 @@
*SVN*
+* 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:
+
+ <%= render_partial "account", person, "rules" => regulations.rules %>
+
+ ...to:
+
+ <%= render_partial "account", :account => person, :rules => regulations.rules %>
+
+ The old API will still work, though, and render_partial "account" will still assume :account => @account.
+
* 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]
* Fixed pagination to work with joins #1034 [scott@sigkill.org]
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index e7020421c5..c8a012afda 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -242,7 +242,7 @@ module ActionController #:nodoc:
cattr_accessor :ignore_missing_templates
# Holds the request object that's primarily used to get environment variables through access like
- # <tt>@request.env["REQUEST_URI"]</tt>.
+ # <tt>request.env["REQUEST_URI"]</tt>.
attr_accessor :request
# Holds a hash of all the GET, POST, and Url parameters passed to the action. Accessed like <tt>@params["post_id"]</tt>
@@ -250,16 +250,16 @@ module ActionController #:nodoc:
attr_accessor :params
# Holds the response object that's primarily used to set additional HTTP headers through access like
- # <tt>@response.headers["Cache-Control"] = "no-cache"</tt>. Can also be used to access the final body HTML after a template
- # has been rendered through @response.body -- useful for <tt>after_filter</tt>s that wants to manipulate the output,
+ # <tt>response.headers["Cache-Control"] = "no-cache"</tt>. Can also be used to access the final body HTML after a template
+ # has been rendered through response.body -- useful for <tt>after_filter</tt>s that wants to manipulate the output,
# such as a OutputCompressionFilter.
attr_accessor :response
- # Holds a hash of objects in the session. Accessed like <tt>@session["person"]</tt> to get the object tied to the "person"
+ # Holds a hash of objects in the session. Accessed like <tt>session[:person]</tt> to get the object tied to the "person"
# key. The session will hold any type of object as values, but the key should be a string.
attr_accessor :session
- # Holds a hash of header names and values. Accessed like <tt>@headers["Cache-Control"]</tt> to get the value of the Cache-Control
+ # Holds a hash of header names and values. Accessed like <tt>headers["Cache-Control"]</tt> to get the value of the Cache-Control
# directive. Values should always be specified as strings.
attr_accessor :headers
diff --git a/actionpack/lib/action_view/partials.rb b/actionpack/lib/action_view/partials.rb
index cfe53858b4..fa12067c82 100644
--- a/actionpack/lib/action_view/partials.rb
+++ b/actionpack/lib/action_view/partials.rb
@@ -1,14 +1,25 @@
module ActionView
# There's also a convenience method for rendering sub templates within the current controller that depends on a single object
# (we call this kind of sub templates for partials). It relies on the fact that partials should follow the naming convention of being
- # prefixed with an underscore -- as to separate them from regular templates that could be rendered on their own. In the template for
- # Advertiser#buy, we could have:
+ # prefixed with an underscore -- as to separate them from regular templates that could be rendered on their own.
+ #
+ # In a template for Advertiser#account:
+ #
+ # <%= render_partial "account" %>
+ #
+ # This would render "advertiser/_account.rhtml" and pass the instance variable @account in as a local variable +account+ to
+ # the template for display.
+ #
+ # In another template for Advertiser#buy, we could have:
+ #
+ # <%= render_partial "account", :account => @buyer %>
#
# <% for ad in @advertisements %>
- # <%= render_partial "ad", ad %>
+ # <%= render_partial "ad", :ad => ad %>
# <% end %>
#
- # This would render "advertiser/_ad.rhtml" and pass the local variable +ad+ to the template for display.
+ # This would first render "advertiser/_account.rhtml" with @buyer passed in as the local variable +account+, then render
+ # "advertiser/_ad.rhtml" and pass the local variable +ad+ to the template for display.
#
# == Rendering a collection of partials
#
@@ -27,7 +38,7 @@ module ActionView
#
# Two controllers can share a set of partials and render them like this:
#
- # <%= render_partial "advertisement/ad", ad %>
+ # <%= render_partial "advertisement/ad", :ad => @advertisement %>
#
# This will render the partial "advertisement/_ad.rhtml" regardless of which controller this is being called from.
module Partials