From 1d84c158c1aff15149a91b86f44138d96e417134 Mon Sep 17 00:00:00 2001
From: Mike Gunderloy
Date: Sat, 1 Nov 2008 06:14:02 -0500
Subject: Update 2.2 relnotes & Layouts/Rendering Guide to include render :js
---
railties/doc/guides/html/2_2_release_notes.html | 7 ++++++-
railties/doc/guides/html/layouts_and_rendering.html | 21 ++++++++++++++++++---
railties/doc/guides/source/2_2_release_notes.txt | 3 ++-
.../doc/guides/source/layouts_and_rendering.txt | 12 ++++++++++++
4 files changed, 38 insertions(+), 5 deletions(-)
(limited to 'railties/doc')
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
-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.
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 -->
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. |
-2.2.10. Options for render
+2.2.10. Rendering Vanilla JavaScript
+Rails can render vanilla JavaScript (as an alternative to using update with n .rjs file):
+
+
+
render :js => "alert('Hello Rails');"
+
+This will send the supplied string to the browser with a MIME type of text/javascript.
+2.2.11. Options for render
Calls to the render method generally accept four options:
-2.2.11. Finding Layouts
+2.2.12. Finding Layouts
To find the current layout, Rails first looks for a file in app/views/layouts with the same base name as the controller. For example, rendering actions from the PhotosController class will use /app/views/layouts/photos.html.erb. If there is no such controller-specific layout, Rails will use /app/views/layouts/application.html.erb. If there is no .erb layout, Rails will use a .builder layout if one exists. Rails also provides several ways to more precisely assign specific layouts to individual controllers and actions.
Specifying Layouts on a per-Controller Basis
You can override the automatic layout conventions in your controllers by using the layout declaration in the controller. For example:
@@ -693,7 +703,7 @@ In general, views will be rendered in the main layout
-2.2.12. Avoiding Double Render Errors
+2.2.13. Avoiding Double Render Errors
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 render works.
For example, here's some code that will trigger this error:
@@ -1309,6 +1319,11 @@ _employee.html.erb:
-
+November 1, 2008: Added :js option for render by Mike Gunderloy
+
+
+-
+
October 16, 2008: Ready for publication by Mike Gunderloy
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)
--
cgit v1.2.3