diff options
author | Mike Gunderloy <MikeG1@larkfarm.com> | 2008-11-01 06:14:02 -0500 |
---|---|---|
committer | Mike Gunderloy <MikeG1@larkfarm.com> | 2008-11-01 06:14:02 -0500 |
commit | 1d84c158c1aff15149a91b86f44138d96e417134 (patch) | |
tree | adb1117c4c6f6fc66340b648d154586572b2e2a1 /railties/doc | |
parent | 4bb13a2bfb7a2fc666c74038c1e72ea10544dfae (diff) | |
download | rails-1d84c158c1aff15149a91b86f44138d96e417134.tar.gz rails-1d84c158c1aff15149a91b86f44138d96e417134.tar.bz2 rails-1d84c158c1aff15149a91b86f44138d96e417134.zip |
Update 2.2 relnotes & Layouts/Rendering Guide to include render :js
Diffstat (limited to 'railties/doc')
4 files changed, 38 insertions, 5 deletions
diff --git a/railties/doc/guides/html/2_2_release_notes.html b/railties/doc/guides/html/2_2_release_notes.html index d83ad87160..c68f10ad5a 100644 --- a/railties/doc/guides/html/2_2_release_notes.html +++ b/railties/doc/guides/html/2_2_release_notes.html @@ -781,7 +781,12 @@ Rails now supports HTTP-only cookies (and uses them for sessions), which help mi </li>
<li>
<p>
-<tt>redirect_to</tt> now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI)
+<tt>redirect_to</tt> now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI).
+</p>
+</li>
+<li>
+<p>
+<tt>render</tt> now supports a <tt>:js</tt> option to render plain vanilla javascript with the right mime type.
</p>
</li>
</ul></div>
diff --git a/railties/doc/guides/html/layouts_and_rendering.html b/railties/doc/guides/html/layouts_and_rendering.html index bf790d7b9d..8f78429610 100644 --- a/railties/doc/guides/html/layouts_and_rendering.html +++ b/railties/doc/guides/html/layouts_and_rendering.html @@ -489,7 +489,17 @@ http://www.gnu.org/software/src-highlite --> <td class="content">You don't need to call <tt>to_xml</tt> on the object that you want to render. If you use the <tt>:xml</tt> option, <tt>render</tt> will automatically call <tt>to_xml</tt> for you.</td>
</tr></table>
</div>
-<h4 id="_options_for_tt_render_tt">2.2.10. Options for <tt>render</tt></h4>
+<h4 id="_rendering_vanilla_javascript">2.2.10. Rendering Vanilla JavaScript</h4>
+<div class="para"><p>Rails can render vanilla JavaScript (as an alternative to using <tt>update</tt> with n <tt>.rjs</tt> file):</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>render <span style="color: #990000">:</span>js <span style="color: #990000">=></span> <span style="color: #FF0000">"alert('Hello Rails');"</span>
+</tt></pre></div></div>
+<div class="para"><p>This will send the supplied string to the browser with a MIME type of <tt>text/javascript</tt>.</p></div>
+<h4 id="_options_for_tt_render_tt">2.2.11. Options for <tt>render</tt></h4>
<div class="para"><p>Calls to the <tt>render</tt> method generally accept four options:</p></div>
<div class="ilist"><ul>
<li>
@@ -560,7 +570,7 @@ http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite -->
<pre><tt>render <span style="color: #990000">:</span>xml <span style="color: #990000">=></span> photo<span style="color: #990000">,</span> <span style="color: #990000">:</span>location <span style="color: #990000">=></span> photo_url<span style="color: #990000">(</span>photo<span style="color: #990000">)</span>
</tt></pre></div></div>
-<h4 id="_finding_layouts">2.2.11. Finding Layouts</h4>
+<h4 id="_finding_layouts">2.2.12. Finding Layouts</h4>
<div class="para"><p>To find the current layout, Rails first looks for a file in <tt>app/views/layouts</tt> with the same base name as the controller. For example, rendering actions from the <tt>PhotosController</tt> class will use <tt>/app/views/layouts/photos.html.erb</tt>. If there is no such controller-specific layout, Rails will use <tt>/app/views/layouts/application.html.erb</tt>. If there is no <tt>.erb</tt> layout, Rails will use a <tt>.builder</tt> layout if one exists. Rails also provides several ways to more precisely assign specific layouts to individual controllers and actions.</p></div>
<h5 id="_specifying_layouts_on_a_per_controller_basis">Specifying Layouts on a per-Controller Basis</h5>
<div class="para"><p>You can override the automatic layout conventions in your controllers by using the <tt>layout</tt> declaration in the controller. For example:</p></div>
@@ -693,7 +703,7 @@ In general, views will be rendered in the <tt>main</tt> layout </p>
</li>
</ul></div>
-<h4 id="_avoiding_double_render_errors">2.2.12. Avoiding Double Render Errors</h4>
+<h4 id="_avoiding_double_render_errors">2.2.13. Avoiding Double Render Errors</h4>
<div class="para"><p>Sooner or later, most Rails developers will see the error message "Can only render or redirect once per action". While this is annoying, it's relatively easy to fix. Usually it happens because of a fundamental misunderstanding of the way that <tt>render</tt> works.</p></div>
<div class="para"><p>For example, here's some code that will trigger this error:</p></div>
<div class="listingblock">
@@ -1309,6 +1319,11 @@ _employee.html.erb: <div class="ilist"><ul>
<li>
<p>
+November 1, 2008: Added <tt>:js</tt> option for <tt>render</tt> by <a href="../authors.html#mgunderloy">Mike Gunderloy</a>
+</p>
+</li>
+<li>
+<p>
October 16, 2008: Ready for publication by <a href="../authors.html#mgunderloy">Mike Gunderloy</a>
</p>
</li>
diff --git a/railties/doc/guides/source/2_2_release_notes.txt b/railties/doc/guides/source/2_2_release_notes.txt index c49b85e737..2e9e9b8aa1 100644 --- a/railties/doc/guides/source/2_2_release_notes.txt +++ b/railties/doc/guides/source/2_2_release_notes.txt @@ -257,7 +257,8 @@ Action Controller now offers good support for HTTP conditional GET requests, as * The HTTP Accept header is disabled by default now. You should prefer the use of formatted URLs (such as +/customers/1.xml+) to indicate the format that you want. If you need the Accept headers, you can turn them back on with +config.action_controller.user_accept_header = true+. * Benchmarking numbers are now reported in milliseconds rather than tiny fractions of seconds * Rails now supports HTTP-only cookies (and uses them for sessions), which help mitigate some cross-site scripting risks in newer browsers. -* +redirect_to+ now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI) +* +redirect_to+ now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI). +* +render+ now supports a +:js+ option to render plain vanilla javascript with the right mime type. == Action View diff --git a/railties/doc/guides/source/layouts_and_rendering.txt b/railties/doc/guides/source/layouts_and_rendering.txt index 0c8ed43e26..4211f9a0b5 100644 --- a/railties/doc/guides/source/layouts_and_rendering.txt +++ b/railties/doc/guides/source/layouts_and_rendering.txt @@ -166,6 +166,17 @@ render :xml => @product TIP: You don't need to call +to_xml+ on the object that you want to render. If you use the +:xml+ option, +render+ will automatically call +to_xml+ for you. +==== Rendering Vanilla JavaScript + +Rails can render vanilla JavaScript (as an alternative to using +update+ with n +.rjs+ file): + +[source, ruby] +------------------------------------------------------- +render :js => "alert('Hello Rails');" +------------------------------------------------------- + +This will send the supplied string to the browser with a MIME type of +text/javascript+. + ==== Options for +render+ Calls to the +render+ method generally accept four options: @@ -885,6 +896,7 @@ In this case, Rails will use the customer or employee partials as appropriate fo http://rails.lighthouseapp.com/projects/16213-rails-guides/tickets/15[Lighthouse ticket] +* November 1, 2008: Added +:js+ option for +render+ by link:../authors.html#mgunderloy[Mike Gunderloy] * October 16, 2008: Ready for publication by link:../authors.html#mgunderloy[Mike Gunderloy] * October 4, 2008: Additional info on partials (+:object+, +:as+, and +:spacer_template+) by link:../authors.html#mgunderloy[Mike Gunderloy] (not yet approved for publication) * September 28, 2008: First draft by link:../authors.html#mgunderloy[Mike Gunderloy] (not yet approved for publication) |