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
vijaydev committed Apr 1, 2012
2 parents eb154c5 + a5a9fc9 commit cf18298
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class InvalidAuthenticityToken < ActionControllerError #:nodoc:
# CSRF protection is turned on with the <tt>protect_from_forgery</tt> method,
# which checks the token and resets the session if it doesn't match what was expected.
# A call to this method is generated for new \Rails applications by default.
# You can customize the error message by editing public/422.html.
#
# The token parameter is named <tt>authenticity_token</tt> by default. The name and
# value of this token must be added to every layout that renders forms by including
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module ResponseAssertions

# Asserts that the response is one of the following types:
#
# * <tt>:success</tt> - Status code was 200
# * <tt>:success</tt> - Status code was in the 200-299 range
# * <tt>:redirect</tt> - Status code was in the 300-399 range
# * <tt>:missing</tt> - Status code was 404
# * <tt>:error</tt> - Status code was in the 500-599 range
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/form_tag_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def form_tag(url_for_options = {}, options = {}, &block)
# # => <select id="colors" multiple="multiple" name="colors[]"><option>Red</option>
# # <option>Green</option><option>Blue</option></select>
#
# select_tag "locations", "<option>Home</option><option selected="selected">Work</option><option>Out</option>".html_safe
# select_tag "locations", "<option>Home</option><option selected='selected'>Work</option><option>Out</option>".html_safe
# # => <select id="locations" name="locations"><option>Home</option><option selected='selected'>Work</option>
# # <option>Out</option></select>
#
Expand Down
6 changes: 3 additions & 3 deletions guides/assets/stylesheets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ body {
font-family: Helvetica, Arial, sans-serif;
font-size: 87.5%;
line-height: 1.5em;
background: #222;
background: #fff;
min-width: 69em;
color: #999;
}
Expand All @@ -94,6 +94,7 @@ body {
#topNav {
padding: 1em 0;
color: #565656;
background: #222;
}

#header {
Expand All @@ -111,7 +112,6 @@ body {
}

#container {
background: #FFF;
color: #333;
padding: 0.5em 0 1.5em 0;
}
Expand All @@ -137,7 +137,7 @@ body {

#footer {
padding: 2em 0;
background: url(../images/footer_tile.gif) repeat-x;
background: #222 url(../images/footer_tile.gif) repeat-x;
}
#footer .wrapper {
padding-left: 2em;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Generate digests for assets URLs.
config.assets.digest = true

# Defaults to Rails.root.join("public/assets").
# Defaults to nil
# config.assets.manifest = YOUR_PATH

# Specifies the header that your server uses for sending files.
Expand Down
2 changes: 1 addition & 1 deletion guides/source/asset_pipeline.textile
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ config.assets.compile = false
# Generate digests for assets URLs.
config.assets.digest = true

# Defaults to Rails.root.join("public/assets")
# Defaults to nil and saved in location specified by config.assets.prefix
# config.assets.manifest = YOUR_PATH

# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
Expand Down
6 changes: 3 additions & 3 deletions guides/source/engines.textile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ end

By inheriting from the +Rails::Engine+ class, this gem notifies Rails that there's an engine at the specified path, and will correctly mount the engine inside the application, performing tasks such as adding the +app+ directory of the engine to the load path for models, mailers, controllers and views.

The +isolate_namespace+ method here deserves special notice. This call is responsible for isolating the controllers, models, routes and other things into their own namespace, away from similar components inside hte application. Without this, there is a possibility that the engine's components could "leak" into the application, causing unwanted disruption, or that important engine components could be overriden by similarly named things within the application. One of the examples of such conflicts are helpers. Without calling +isolate_namespace+, engine's helpers would be included in application's controllers.
The +isolate_namespace+ method here deserves special notice. This call is responsible for isolating the controllers, models, routes and other things into their own namespace, away from similar components inside the application. Without this, there is a possibility that the engine's components could "leak" into the application, causing unwanted disruption, or that important engine components could be overridden by similarly named things within the application. One of the examples of such conflicts are helpers. Without calling +isolate_namespace+, engine's helpers would be included in application's controllers.

NOTE: It is *highly* recommended that the +isolate_namespace+ line be left within the +Engine+ class definition. Without it, classes generated in an engine *may* conflict with an application.

Expand Down Expand Up @@ -665,7 +665,7 @@ Try this now by creating a new file at +app/views/blorgh/posts/index.html.erb+ a

Rather than looking like the default scaffold, the page will now look like this:

!images/engines_post_override.png(Engine scaffold overriden)!
!images/engines_post_override.png(Engine scaffold overridden)!

h4. Routes

Expand Down Expand Up @@ -736,7 +736,7 @@ You can define assets for precompilation in +engine.rb+
initializer do |app|
app.config.assets.precompile += %w(admin.css admin.js)
end
</ruby
</ruby>

For more information, read the "Asset Pipeline guide":http://guides.rubyonrails.org/asset_pipeline.html

Expand Down
14 changes: 7 additions & 7 deletions guides/source/layouts_and_rendering.textile
Original file line number Diff line number Diff line change
Expand Up @@ -1134,13 +1134,6 @@ In Rails 3.0, there is also a shorthand for this. Assuming +@products+ is a coll

Rails determines the name of the partial to use by looking at the model name in the collection. In fact, you can even create a heterogeneous collection and render it this way, and Rails will choose the proper partial for each member of the collection:

In the event that the collection is empty, +render+ will return nil, so it should be fairly simple to provide alternative content.

<erb>
<h1>Products</h1>
<%= render(@products) || 'There are no products available.' %>
</erb>

* +index.html.erb+

<erb>
Expand All @@ -1162,6 +1155,13 @@ In the event that the collection is empty, +render+ will return nil, so it shoul

In this case, Rails will use the customer or employee partials as appropriate for each member of the collection.

In the event that the collection is empty, +render+ will return nil, so it should be fairly simple to provide alternative content.

<erb>
<h1>Products</h1>
<%= render(@products) || 'There are no products available.' %>
</erb>

h5. Local Variables

To use a custom local variable name within the partial, specify the +:as+ option in the call to the partial:
Expand Down
11 changes: 11 additions & 0 deletions guides/source/routing.textile
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,17 @@ TwitterClone::Application.routes.draw do
end
</ruby>

You can also specify constraints as a lambda:

<ruby>
TwitterClone::Application.routes.draw do
match "*path" => "blacklist#index",
:constraints => lambda { |request| Blacklist.retrieve_ips.include?(request.remote_ip) }
end
</ruby>

Both the +matches?+ method and the lambda gets the +request+ object as an argument.

h4. Route Globbing

Route globbing is a way to specify that a particular parameter should be matched to all the remaining parts of a route. For example
Expand Down
2 changes: 1 addition & 1 deletion guides/source/testing.textile
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ NOTE: +assert_valid(record)+ has been deprecated. Please use +assert(record.vali
|+assert_no_difference(expressions, message = nil, &amp;block)+ |Asserts that the numeric result of evaluating an expression is not changed before and after invoking the passed in block.|
|+assert_recognizes(expected_options, path, extras={}, message=nil)+ |Asserts that the routing of the given path was handled correctly and that the parsed options (given in the expected_options hash) match path. Basically, it asserts that Rails recognizes the route given by expected_options.|
|+assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)+ |Asserts that the provided options can be used to generate the provided path. This is the inverse of assert_recognizes. The extras parameter is used to tell the request the names and values of additional request parameters that would be in a query string. The message parameter allows you to specify a custom error message for assertion failures.|
|+assert_response(type, message = nil)+ |Asserts that the response comes with a specific status code. You can specify +:success+ to indicate 200, +:redirect+ to indicate 300-399, +:missing+ to indicate 404, or +:error+ to match the 500-599 range|
|+assert_response(type, message = nil)+ |Asserts that the response comes with a specific status code. You can specify +:success+ to indicate 200-299, +:redirect+ to indicate 300-399, +:missing+ to indicate 404, or +:error+ to match the 500-599 range|
|+assert_redirected_to(options = {}, message=nil)+ |Assert that the redirection options passed in match those of the redirect called in the latest action. This match can be partial, such that +assert_redirected_to(:controller => "weblog")+ will also match the redirection of +redirect_to(:controller => "weblog", :action => "show")+ and so on.|
|+assert_template(expected = nil, message=nil)+ |Asserts that the request was rendered with the appropriate template file.|

Expand Down

0 comments on commit cf18298

Please sign in to comment.