Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lifo/docrails
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Sanghi committed Oct 16, 2010
2 parents 40398a1 + a38e653 commit 5a36f9f
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 28 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/metal/conditional_get.rb
Expand Up @@ -66,7 +66,7 @@ def stale?(options)
# Examples:
# expires_in 20.minutes
# expires_in 3.hours, :public => true
# expires in 3.hours, 'max-stale' => 5.hours, :public => true
# expires_in 3.hours, 'max-stale' => 5.hours, :public => true
#
# This method will overwrite an existing Cache-Control header.
# See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for more possibilities.
Expand Down
10 changes: 0 additions & 10 deletions activerecord/lib/active_record/callbacks.rb
Expand Up @@ -218,16 +218,6 @@ module ActiveRecord
# needs to be aware of it because an ordinary +save+ will raise such exception
# instead of quietly returning +false+.
#
# == Debugging callbacks
#
# To list the methods and procs registered with a particular callback, append <tt>_callback_chain</tt> to
# the callback name that you wish to list and send that to your class from the Rails console:
#
# >> Topic.after_save_callback_chain
# => [#<ActiveSupport::Callbacks::Callback:0x3f6a448
# @method=#<Proc:0x03f9a42c@/Users/foo/bar/app/models/topic.rb:43>, kind:after_save, identifiernil,
# options{}]
#
module Callbacks
extend ActiveSupport::Concern

Expand Down
Expand Up @@ -35,10 +35,16 @@ def html_escape(s)
# A utility method for escaping HTML entities in JSON strings.
# This method is also aliased as <tt>j</tt>.
#
# Note that after this operation is performed the output is not
# a valid JSON.
#
# In your ERb templates, use this method to escape any HTML entities:
# <%=j @person.to_json %>
#
# ==== Example:
# puts json_escape("{\"name\":\"john\",\"created_at\":\"2010-04-28T01:39:31Z\",\"id\":1}")
# # => {name:john,created_at:2010-04-28T01:39:31Z,id:1}
#
# puts json_escape("is a > 0 & a < 10?")
# # => is a \u003E 0 \u0026 a \u003C 10?
def json_escape(s)
Expand Down
Expand Up @@ -235,7 +235,7 @@ This helper validates that the attributes' values are not included in a given se

<ruby>
class Account < ActiveRecord::Base
validates_exclusion_of :subdomain, :in => %w(www),
validates_exclusion_of :subdomain, :in => %w(www us ca jp),
:message => "Subdomain %{value} is reserved."
end
</ruby>
Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/association_basics.textile
Expand Up @@ -550,7 +550,7 @@ build_customer
create_customer
</ruby>

h6(#belongs_to-association). <tt>_association_(force_reload = false)</tt>
h6(#belongs_to-association). <tt><em>association</em>(force_reload = false)</tt>

The <tt><em>association</em></tt> method returns the associated object, if any. If no associated object is found, it returns +nil+.

Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/command_line.textile
Expand Up @@ -145,7 +145,7 @@ $ rails generate controller Greetings hello

What all did this generate? It made sure a bunch of directories were in our application, and created a controller file, a functional test file, a helper for the view, and a view file.

Check out the controller and modify it a little (in +app/controllers/greetings_controller.rb+):ma
Check out the controller and modify it a little (in +app/controllers/greetings_controller.rb+):

<ruby>
class GreetingsController < ApplicationController
Expand Down
4 changes: 1 addition & 3 deletions railties/guides/source/debugging_rails_applications.textile
Expand Up @@ -250,16 +250,14 @@ Make sure you have started your web server with the option +--debugger+:

<shell>
~/PathTo/rails_project$ rails server --debugger
=> Booting Mongrel (use 'rails server webrick' to force WEBrick)
=> Booting WEBrick
=> Rails 3.0.0 application starting on http://0.0.0.0:3000
=> Debugger enabled
...
</shell>

TIP: In development mode, you can dynamically +require \'ruby-debug\'+ instead of restarting the server, if it was started without +--debugger+.

In order to use Rails debugging you'll need to be running either *WEBrick* or *Mongrel*. For the moment, no alternative servers are supported.

h4. The Shell

As soon as your application calls the +debugger+ method, the debugger will be started in a debugger shell inside the terminal window where you launched your application server, and you will be placed at ruby-debug's prompt +(rdb:n)+. The _n_ is the thread number. The prompt will also show you the next line of code that is waiting to run.
Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/form_helpers.textile
Expand Up @@ -67,7 +67,7 @@ A basic search form
<% end %>
</html>

TIP: +search_path+ can be a named route specified in "routes.rb": <br /><tt>map.search "search", :controller => "search"</tt>
TIP: +search_path+ can be a named route specified in "routes.rb" as: <br /><code>match "search" => "search"</code>This declares for path "/search" to call action "search" from controller "search".

The above view code will result in the following markup:

Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/generators.textile
Expand Up @@ -144,7 +144,7 @@ generators/initializer_generator.rb

If none is found you get an error message.

INFO: The examples above put files under the application's +lib+ because said directoty belongs to +$LOAD_PATH+.
INFO: The examples above put files under the application's +lib+ because said directory belongs to +$LOAD_PATH+.

h3. Customizing Your Workflow

Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/getting_started.textile
Expand Up @@ -282,7 +282,7 @@ You actually have a functional Rails application already. To see it, you need to
$ rails server
</shell>

This will fire up an instance of the Mongrel web server by default (Rails can also use several other web servers). To see your application in action, open a browser window and navigate to "http://localhost:3000":http://localhost:3000. You should see Rails' default information page:
This will fire up an instance of the WEBrick web server by default (Rails can also use several other web servers). To see your application in action, open a browser window and navigate to "http://localhost:3000":http://localhost:3000. You should see Rails' default information page:

!images/rails_welcome.png(Welcome Aboard screenshot)!

Expand Down
16 changes: 8 additions & 8 deletions railties/guides/source/layouts_and_rendering.textile
Expand Up @@ -90,7 +90,7 @@ If we want to display the properties of all the books in our view, we can do so
<%= link_to 'New book', new_book_path %>
</ruby>

NOTE: The actual rendering is done by subclasses of +ActionView::TemplateHandlers+. This guide does not dig into that process, but it's important to know that the file extension on your view controls the choice of template handler. In Rails 2, the standard extensions are +.erb+ for ERB (HTML with embedded Ruby), +.rjs+ for RJS (javascript with embedded ruby) and +.builder+ for Builder (XML generator).
NOTE: The actual rendering is done by subclasses of +ActionView::TemplateHandlers+. This guide does not dig into that process, but it's important to know that the file extension on your view controls the choice of template handler. In Rails 2, the standard extensions are +.erb+ for ERB (HTML with embedded Ruby), +.rjs+ for RJS (JavaScript with embedded ruby) and +.builder+ for Builder (XML generator).

h4. Using +render+

Expand Down Expand Up @@ -252,15 +252,15 @@ render :inline =>

h5. Using +render+ with +:update+

You can also render javascript-based page updates inline using the +:update+ option to +render+:
You can also render JavaScript-based page updates inline using the +:update+ option to +render+:

<ruby>
render :update do |page|
page.replace_html 'warning', "Invalid options supplied"
end
</ruby>

WARNING: Placing javascript updates in your controller may seem to streamline small updates, but it defeats the MVC orientation of Rails and will make it harder for other developers to follow the logic of your project. We recommend using a separate rjs template instead, no matter how small the update.
WARNING: Placing JavaScript updates in your controller may seem to streamline small updates, but it defeats the MVC orientation of Rails and will make it harder for other developers to follow the logic of your project. We recommend using a separate RJS template instead, no matter how small the update.

h5. Rendering Text

Expand All @@ -276,7 +276,7 @@ NOTE: By default, if you use the +:text+ option, the text is rendered without us

h5. Rendering JSON

JSON is a javascript data format used by many AJAX libraries. Rails has built-in support for converting objects to JSON and rendering that JSON back to the browser:
JSON is a JavaScript data format used by many AJAX libraries. Rails has built-in support for converting objects to JSON and rendering that JSON back to the browser:

<ruby>
render :json => @product
Expand Down Expand Up @@ -655,7 +655,7 @@ I'll discuss each of these in turn.

h4. Asset Tags

Asset tags provide methods for generating HTML that links views to assets like images, videos, audio, javascript, stylesheets, and feeds. There are six types of include tag:
Asset tags provide methods for generating HTML that links views to assets like images, videos, audio, JavaScript, stylesheets, and feeds. There are six types of include tag:

* +auto_discovery_link_tag+
* +javascript_include_tag+
Expand Down Expand Up @@ -715,7 +715,7 @@ The +defaults+ option loads the Prototype and Scriptaculous libraries:
<%= javascript_include_tag :defaults %>
</erb>

The +all+ option loads every javascript file in +public/javascripts+, starting with the Prototype and Scriptaculous libraries:
The +all+ option loads every JavaScript file in +public/javascripts+, starting with the Prototype and Scriptaculous libraries:

<erb>
<%= javascript_include_tag :all %>
Expand All @@ -727,7 +727,7 @@ You can supply the +:recursive+ option to load files in subfolders of +public/ja
<%= javascript_include_tag :all, :recursive => true %>
</erb>

If you're loading multiple javascript files, you can create a better user experience by combining multiple files into a single download. To make this happen in production, specify +:cache => true+ in your +javascript_include_tag+:
If you're loading multiple JavaScript files, you can create a better user experience by combining multiple files into a single download. To make this happen in production, specify +:cache => true+ in your +javascript_include_tag+:

<erb>
<%= javascript_include_tag "main", "columns", :cache => true %>
Expand Down Expand Up @@ -962,7 +962,7 @@ The result of rendering this page into the supplied layout would be this HTML:
</html>
</erb>

The +content_for+ method is very helpful when your layout contains distinct regions such as sidebars and footers that should get their own blocks of content inserted. It's also useful for inserting tags that load page-specific javascript or css files into the header of an otherwise generic layout.
The +content_for+ method is very helpful when your layout contains distinct regions such as sidebars and footers that should get their own blocks of content inserted. It's also useful for inserting tags that load page-specific JavaScript or css files into the header of an otherwise generic layout.

h4. Using Partials

Expand Down

0 comments on commit 5a36f9f

Please sign in to comment.