提交 3a9b3ba0 编写于 作者: V Vijay Dev

Merge branch 'master' of github.com:rails/docrails

...@@ -13,9 +13,9 @@ module ConditionalGet ...@@ -13,9 +13,9 @@ module ConditionalGet
end end
module ClassMethods module ClassMethods
# Allows you to consider additional controller-wide information when generating an etag. # Allows you to consider additional controller-wide information when generating an ETag.
# For example, if you serve pages tailored depending on who's logged in at the moment, you # For example, if you serve pages tailored depending on who's logged in at the moment, you
# may want to add the current user id to be part of the etag to prevent authorized displaying # may want to add the current user id to be part of the ETag to prevent authorized displaying
# of cached pages. # of cached pages.
# #
# class InvoicesController < ApplicationController # class InvoicesController < ApplicationController
...@@ -32,7 +32,7 @@ def etag(&etagger) ...@@ -32,7 +32,7 @@ def etag(&etagger)
end end
end end
# Sets the etag, +last_modified+, or both on the response and renders a # Sets the +etag+, +last_modified+, or both on the response and renders a
# <tt>304 Not Modified</tt> response if the request is already fresh. # <tt>304 Not Modified</tt> response if the request is already fresh.
# #
# === Parameters: # === Parameters:
...@@ -54,11 +54,11 @@ def etag(&etagger) ...@@ -54,11 +54,11 @@ def etag(&etagger)
# fresh_when(etag: @article, last_modified: @article.created_at, public: true) # fresh_when(etag: @article, last_modified: @article.created_at, public: true)
# end # end
# #
# This will render the show template if the request isn't sending a matching etag or # This will render the show template if the request isn't sending a matching ETag or
# If-Modified-Since header and just a <tt>304 Not Modified</tt> response if there's a match. # If-Modified-Since header and just a <tt>304 Not Modified</tt> response if there's a match.
# #
# You can also just pass a record where +last_modified+ will be set by calling # You can also just pass a record where +last_modified+ will be set by calling
# +updated_at+ and the etag by passing the object itself. # +updated_at+ and the +etag+ by passing the object itself.
# #
# def show # def show
# @article = Article.find(params[:id]) # @article = Article.find(params[:id])
...@@ -124,7 +124,7 @@ def fresh_when(record_or_options, additional_options = {}) ...@@ -124,7 +124,7 @@ def fresh_when(record_or_options, additional_options = {})
# end # end
# #
# You can also just pass a record where +last_modified+ will be set by calling # You can also just pass a record where +last_modified+ will be set by calling
# updated_at and the etag by passing the object itself. # +updated_at+ and the +etag+ by passing the object itself.
# #
# def show # def show
# @article = Article.find(params[:id]) # @article = Article.find(params[:id])
......
...@@ -229,11 +229,11 @@ Please refer to the [Changelog](https://github.com/rails/rails/blob/4-0-stable/a ...@@ -229,11 +229,11 @@ Please refer to the [Changelog](https://github.com/rails/rails/blob/4-0-stable/a
The method `change_table` is also reversible, as long as its block doesn't call `remove`, `change` or `change_default` The method `change_table` is also reversible, as long as its block doesn't call `remove`, `change` or `change_default`
* New method `reversible` makes it possible to specify code to be run when migrating up or down. * New method `reversible` makes it possible to specify code to be run when migrating up or down.
See the [Guide on Migration](https://github.com/rails/rails/blob/master/guides/source/migrations.md#using-the-reversible-method) See the [Guide on Migration](https://github.com/rails/rails/blob/master/guides/source/active_record_migrations.md#using-reversible)
* New method `revert` will revert a whole migration or the given block. * New method `revert` will revert a whole migration or the given block.
If migrating down, the given migration / block is run normally. If migrating down, the given migration / block is run normally.
See the [Guide on Migration](https://github.com/rails/rails/blob/master/guides/source/migrations.md#reverting-previous-migrations) See the [Guide on Migration](https://github.com/rails/rails/blob/master/guides/source/active_record_migrations.md#reverting-previous-migrations)
* Adds PostgreSQL array type support. Any datatype can be used to create an array column, with full migration and schema dumper support. * Adds PostgreSQL array type support. Any datatype can be used to create an array column, with full migration and schema dumper support.
......
...@@ -298,8 +298,7 @@ Action Mailer 3.0 makes inline attachments, which involved a lot of hacking in p ...@@ -298,8 +298,7 @@ Action Mailer 3.0 makes inline attachments, which involved a lot of hacking in p
```html+erb ```html+erb
<p>Hello there, this is our image</p> <p>Hello there, this is our image</p>
<%= image_tag attachments['image.jpg'].url, alt: 'My Photo', <%= image_tag attachments['image.jpg'].url, alt: 'My Photo', class: 'photos' %>
class: 'photos' %>
``` ```
#### Sending Email To Multiple Recipients #### Sending Email To Multiple Recipients
......
...@@ -756,7 +756,7 @@ class Order < ActiveRecord::Base ...@@ -756,7 +756,7 @@ class Order < ActiveRecord::Base
end end
``` ```
Each instance of the order model will have these methods: Each instance of the `Order` model will have these methods:
```ruby ```ruby
customer customer
...@@ -1342,16 +1342,16 @@ class Customer < ActiveRecord::Base ...@@ -1342,16 +1342,16 @@ class Customer < ActiveRecord::Base
end end
``` ```
Each instance of the customer model will have these methods: Each instance of the `Customer` model will have these methods:
```ruby ```ruby
orders(force_reload = false) orders(force_reload = false)
orders<<(object, ...) orders<<(object, ...)
orders.delete(object, ...) orders.delete(object, ...)
orders.destroy(object, ...) orders.destroy(object, ...)
orders=objects orders=(objects)
order_ids order_ids
order_ids=ids order_ids=(ids)
orders.clear orders.clear
orders.empty? orders.empty?
orders.size orders.size
...@@ -1831,16 +1831,16 @@ class Part < ActiveRecord::Base ...@@ -1831,16 +1831,16 @@ class Part < ActiveRecord::Base
end end
``` ```
Each instance of the part model will have these methods: Each instance of the `Part` model will have these methods:
```ruby ```ruby
assemblies(force_reload = false) assemblies(force_reload = false)
assemblies<<(object, ...) assemblies<<(object, ...)
assemblies.delete(object, ...) assemblies.delete(object, ...)
assemblies.destroy(object, ...) assemblies.destroy(object, ...)
assemblies=objects assemblies=(objects)
assembly_ids assembly_ids
assembly_ids=ids assembly_ids=(ids)
assemblies.clear assemblies.clear
assemblies.empty? assemblies.empty?
assemblies.size assemblies.size
......
...@@ -506,6 +506,12 @@ As the name implies, this only generates option tags. To generate a working sele ...@@ -506,6 +506,12 @@ As the name implies, this only generates option tags. To generate a working sele
<%= collection_select(:person, :city_id, City.all, :id, :name) %> <%= collection_select(:person, :city_id, City.all, :id, :name) %>
``` ```
As with other helpers, if you were to use the collection_select helper on a form builder scoped to the @person object, the syntax would be:
```erb
<%= f.collection_select(:city_id, City.all, :id, :name) %>
```
To recap, `options_from_collection_for_select` is to `collection_select` what `options_for_select` is to `select`. To recap, `options_from_collection_for_select` is to `collection_select` what `options_for_select` is to `select`.
NOTE: Pairs passed to `options_for_select` should have the name first and the id second, however with `options_from_collection_for_select` the first argument is the value method and the second the text method. NOTE: Pairs passed to `options_for_select` should have the name first and the id second, however with `options_from_collection_for_select` the first argument is the value method and the second the text method.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册