rails 4.2.0.beta1 → 4.2.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/guides/rails_guides/markdown.rb +6 -1
- data/guides/source/2_2_release_notes.md +1 -1
- data/guides/source/2_3_release_notes.md +1 -1
- data/guides/source/3_0_release_notes.md +2 -2
- data/guides/source/3_1_release_notes.md +4 -1
- data/guides/source/3_2_release_notes.md +4 -1
- data/guides/source/4_0_release_notes.md +4 -1
- data/guides/source/4_1_release_notes.md +4 -4
- data/guides/source/4_2_release_notes.md +272 -45
- data/guides/source/action_controller_overview.md +3 -3
- data/guides/source/action_mailer_basics.md +28 -4
- data/guides/source/action_view_overview.md +11 -11
- data/guides/source/active_job_basics.md +99 -63
- data/guides/source/active_record_postgresql.md +2 -1
- data/guides/source/active_record_querying.md +7 -9
- data/guides/source/active_support_core_extensions.md +48 -2
- data/guides/source/asset_pipeline.md +200 -18
- data/guides/source/association_basics.md +8 -8
- data/guides/source/caching_with_rails.md +1 -1
- data/guides/source/command_line.md +1 -1
- data/guides/source/configuring.md +7 -7
- data/guides/source/contributing_to_ruby_on_rails.md +17 -0
- data/guides/source/debugging_rails_applications.md +2 -2
- data/guides/source/development_dependencies_install.md +41 -43
- data/guides/source/form_helpers.md +17 -17
- data/guides/source/generators.md +6 -2
- data/guides/source/getting_started.md +1 -1
- data/guides/source/i18n.md +16 -0
- data/guides/source/initialization.md +0 -2
- data/guides/source/layouts_and_rendering.md +2 -1
- data/guides/source/maintenance_policy.md +6 -3
- data/guides/source/nested_model_forms.md +4 -1
- data/guides/source/routing.md +1 -1
- data/guides/source/testing.md +2 -2
- data/guides/source/upgrading_ruby_on_rails.md +94 -23
- metadata +18 -18
@@ -559,6 +559,23 @@ $ git push origin my_pull_request -f
|
|
559
559
|
You should be able to refresh the pull request on GitHub and see that it has
|
560
560
|
been updated.
|
561
561
|
|
562
|
+
#### Updating pull request
|
563
|
+
|
564
|
+
Sometimes you will be asked to make some changes to the code you have
|
565
|
+
already committed. This can include amending existing commits. In this
|
566
|
+
case Git will not allow you to push the changes as the pushed branch
|
567
|
+
and local branch do not match. Instead of opening a new pull request,
|
568
|
+
you can force push to your branch on GitHub as described earlier in
|
569
|
+
squashing commits section:
|
570
|
+
|
571
|
+
```bash
|
572
|
+
$ git push origin my_pull_request -f
|
573
|
+
```
|
574
|
+
|
575
|
+
This will update the branch and pull request on GitHub with your new code. Do
|
576
|
+
note that using force push may result in commits being lost on the remote branch; use it with care.
|
577
|
+
|
578
|
+
|
562
579
|
### Older Versions of Ruby on Rails
|
563
580
|
|
564
581
|
If you want to add a fix to older versions of Ruby on Rails, you'll need to set up and switch to your own local tracking branch. Here is an example to switch to the 4-0-stable branch:
|
@@ -138,7 +138,7 @@ Rails.logger.level = 0 # at any time
|
|
138
138
|
|
139
139
|
This is useful when you want to log under development or staging, but you don't want to flood your production log with unnecessary information.
|
140
140
|
|
141
|
-
TIP: The default Rails log level is `
|
141
|
+
TIP: The default Rails log level is `debug` in all environments.
|
142
142
|
|
143
143
|
### Sending Messages
|
144
144
|
|
@@ -211,7 +211,7 @@ logger.tagged("BCX") { logger.tagged("Jason") { logger.info "Stuff" } } # Logs "
|
|
211
211
|
|
212
212
|
### Impact of Logs on Performance
|
213
213
|
Logging will always have a small impact on performance of your rails app,
|
214
|
-
particularly when logging to disk.However, there are a few subtleties:
|
214
|
+
particularly when logging to disk. However, there are a few subtleties:
|
215
215
|
|
216
216
|
Using the `:debug` level will have a greater performance penalty than `:fatal`,
|
217
217
|
as a far greater number of strings are being evaluated and written to the
|
@@ -45,36 +45,14 @@ $ cd rails
|
|
45
45
|
|
46
46
|
The test suite must pass with any submitted code. No matter whether you are writing a new patch, or evaluating someone else's, you need to be able to run the tests.
|
47
47
|
|
48
|
-
Install first
|
48
|
+
Install first SQLite3 and its development files for the `sqlite3` gem. Mac OS X
|
49
|
+
users are done with:
|
49
50
|
|
50
51
|
```bash
|
51
|
-
$
|
52
|
+
$ brew install sqlite3
|
52
53
|
```
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
```bash
|
57
|
-
$ sudo yum install libxml2 libxml2-devel libxslt libxslt-devel
|
58
|
-
```
|
59
|
-
|
60
|
-
If you are running Arch Linux, you're done with:
|
61
|
-
|
62
|
-
```bash
|
63
|
-
$ sudo pacman -S libxml2 libxslt
|
64
|
-
```
|
65
|
-
|
66
|
-
On FreeBSD, you just have to run:
|
67
|
-
|
68
|
-
```bash
|
69
|
-
# pkg_add -r libxml2 libxslt
|
70
|
-
```
|
71
|
-
|
72
|
-
Alternatively, you can install the `textproc/libxml2` and `textproc/libxslt`
|
73
|
-
ports.
|
74
|
-
|
75
|
-
If you have any problems with these libraries, you can install them manually by compiling the source code. Just follow the instructions at the [Red Hat/CentOS section of the Nokogiri tutorials](http://nokogiri.org/tutorials/installing_nokogiri.html#red_hat__centos) .
|
76
|
-
|
77
|
-
Also, SQLite3 and its development files for the `sqlite3-ruby` gem - in Ubuntu you're done with just
|
55
|
+
In Ubuntu you're done with just:
|
78
56
|
|
79
57
|
```bash
|
80
58
|
$ sudo apt-get install sqlite3 libsqlite3-dev
|
@@ -95,7 +73,7 @@ $ sudo pacman -S sqlite
|
|
95
73
|
For FreeBSD users, you're done with:
|
96
74
|
|
97
75
|
```bash
|
98
|
-
#
|
76
|
+
# pkg install sqlite3
|
99
77
|
```
|
100
78
|
|
101
79
|
Or compile the `databases/sqlite3` port.
|
@@ -117,7 +95,7 @@ This command will install all dependencies except the MySQL and PostgreSQL Ruby
|
|
117
95
|
|
118
96
|
NOTE: If you would like to run the tests that use memcached, you need to ensure that you have it installed and running.
|
119
97
|
|
120
|
-
You can use [Homebrew](http://brew.sh/) to install memcached on
|
98
|
+
You can use [Homebrew](http://brew.sh/) to install memcached on OS X:
|
121
99
|
|
122
100
|
```bash
|
123
101
|
$ brew install memcached
|
@@ -135,6 +113,20 @@ Or use yum on Fedora or CentOS:
|
|
135
113
|
$ sudo yum install memcached
|
136
114
|
```
|
137
115
|
|
116
|
+
If you are running on Arch Linux:
|
117
|
+
|
118
|
+
```bash
|
119
|
+
$ sudo pacman -S memcached
|
120
|
+
```
|
121
|
+
|
122
|
+
For FreeBSD users, you're done with:
|
123
|
+
|
124
|
+
```bash
|
125
|
+
# pkg install memcached
|
126
|
+
```
|
127
|
+
|
128
|
+
Alternatively, you can compile the `databases/memcached` port.
|
129
|
+
|
138
130
|
With the dependencies now installed, you can run the test suite with:
|
139
131
|
|
140
132
|
```bash
|
@@ -181,7 +173,19 @@ The Active Record test suite requires a custom config file: `activerecord/test/c
|
|
181
173
|
|
182
174
|
#### MySQL and PostgreSQL
|
183
175
|
|
184
|
-
To be able to run the suite for MySQL and PostgreSQL we need their gems. Install
|
176
|
+
To be able to run the suite for MySQL and PostgreSQL we need their gems. Install
|
177
|
+
first the servers, their client libraries, and their development files.
|
178
|
+
|
179
|
+
On OS X, you can run:
|
180
|
+
|
181
|
+
```bash
|
182
|
+
$ brew install mysql
|
183
|
+
$ brew install postgresql
|
184
|
+
```
|
185
|
+
|
186
|
+
Follow the instructions given by Homebrew to start these.
|
187
|
+
|
188
|
+
In Ubuntu just run:
|
185
189
|
|
186
190
|
```bash
|
187
191
|
$ sudo apt-get install mysql-server libmysqlclient15-dev
|
@@ -206,17 +210,9 @@ $ sudo pacman -S postgresql postgresql-libs
|
|
206
210
|
FreeBSD users will have to run the following:
|
207
211
|
|
208
212
|
```bash
|
209
|
-
#
|
210
|
-
#
|
211
|
-
```
|
212
|
-
|
213
|
-
You can use [Homebrew](http://brew.sh/) to install MySQL and PostgreSQL on OSX:
|
214
|
-
|
215
|
-
```bash
|
216
|
-
$ brew install mysql
|
217
|
-
$ brew install postgresql
|
213
|
+
# pkg install mysql56-client mysql56-server
|
214
|
+
# pkg install postgresql93-client postgresql93-server
|
218
215
|
```
|
219
|
-
Follow instructions given by [Homebrew](http://brew.sh/) to start these.
|
220
216
|
|
221
217
|
Or install them through ports (they are located under the `databases` folder).
|
222
218
|
If you run into troubles during the installation of MySQL, please see
|
@@ -252,18 +248,20 @@ $ cd activerecord
|
|
252
248
|
$ bundle exec rake db:mysql:build
|
253
249
|
```
|
254
250
|
|
255
|
-
PostgreSQL's authentication works differently.
|
256
|
-
|
251
|
+
PostgreSQL's authentication works differently. To setup the development environment
|
252
|
+
with your development account, on Linux or BSD, you just have to run:
|
257
253
|
|
258
254
|
```bash
|
259
255
|
$ sudo -u postgres createuser --superuser $USER
|
260
256
|
```
|
261
|
-
|
257
|
+
|
258
|
+
and for OS X:
|
259
|
+
|
262
260
|
```bash
|
263
261
|
$ createuser --superuser $USER
|
264
262
|
```
|
265
263
|
|
266
|
-
|
264
|
+
Then you need to create the test databases with
|
267
265
|
|
268
266
|
```bash
|
269
267
|
$ cd activerecord
|
@@ -276,7 +276,7 @@ The name passed to `form_for` controls the key used in `params` to access the fo
|
|
276
276
|
|
277
277
|
The helper methods called on the form builder are identical to the model object helpers except that it is not necessary to specify which object is being edited since this is already managed by the form builder.
|
278
278
|
|
279
|
-
You can create a similar binding without actually creating `<form>` tags with the `fields_for` helper. This is useful for editing additional model objects with the same form. For example if you had a `Person` model with an associated `ContactDetail` model you could create a form for creating both like so:
|
279
|
+
You can create a similar binding without actually creating `<form>` tags with the `fields_for` helper. This is useful for editing additional model objects with the same form. For example, if you had a `Person` model with an associated `ContactDetail` model, you could create a form for creating both like so:
|
280
280
|
|
281
281
|
```erb
|
282
282
|
<%= form_for @person, url: {action: "create"} do |person_form| %>
|
@@ -534,7 +534,7 @@ Both of these families of helpers will create a series of select boxes for the d
|
|
534
534
|
|
535
535
|
### Barebones Helpers
|
536
536
|
|
537
|
-
The `select_*` family of helpers take as their first argument an instance of `Date`, `Time` or `DateTime` that is used as the currently selected value. You may omit this parameter, in which case the current date is used. For example
|
537
|
+
The `select_*` family of helpers take as their first argument an instance of `Date`, `Time` or `DateTime` that is used as the currently selected value. You may omit this parameter, in which case the current date is used. For example:
|
538
538
|
|
539
539
|
```erb
|
540
540
|
<%= select_date Date.today, prefix: :start_date %>
|
@@ -548,7 +548,7 @@ outputs (with actual option values omitted for brevity)
|
|
548
548
|
<select id="start_date_day" name="start_date[day]"> ... </select>
|
549
549
|
```
|
550
550
|
|
551
|
-
The above inputs would result in `params[:start_date]` being a hash with keys `:year`, `:month`, `:day`. To get an actual `Date`, `Time` or `DateTime` object you would have to extract these values and pass them to the appropriate constructor, for example
|
551
|
+
The above inputs would result in `params[:start_date]` being a hash with keys `:year`, `:month`, `:day`. To get an actual `Date`, `Time` or `DateTime` object you would have to extract these values and pass them to the appropriate constructor, for example:
|
552
552
|
|
553
553
|
```ruby
|
554
554
|
Date.civil(params[:start_date][:year].to_i, params[:start_date][:month].to_i, params[:start_date][:day].to_i)
|
@@ -591,9 +591,9 @@ NOTE: In many cases the built-in date pickers are clumsy as they do not aid the
|
|
591
591
|
|
592
592
|
### Individual Components
|
593
593
|
|
594
|
-
Occasionally you need to display just a single date component such as a year or a month. Rails provides a series of helpers for this, one for each component `select_year`, `select_month`, `select_day`, `select_hour`, `select_minute`, `select_second`. These helpers are fairly straightforward. By default they will generate an input field named after the time component (for example "year" for `select_year`, "month" for `select_month` etc.) although this can be overridden with the `:field_name` option. The `:prefix` option works in the same way that it does for `select_date` and `select_time` and has the same default value.
|
594
|
+
Occasionally you need to display just a single date component such as a year or a month. Rails provides a series of helpers for this, one for each component `select_year`, `select_month`, `select_day`, `select_hour`, `select_minute`, `select_second`. These helpers are fairly straightforward. By default they will generate an input field named after the time component (for example, "year" for `select_year`, "month" for `select_month` etc.) although this can be overridden with the `:field_name` option. The `:prefix` option works in the same way that it does for `select_date` and `select_time` and has the same default value.
|
595
595
|
|
596
|
-
The first parameter specifies which value should be selected and can either be an instance of a `Date`, `Time` or `DateTime`, in which case the relevant component will be extracted, or a numerical value. For example
|
596
|
+
The first parameter specifies which value should be selected and can either be an instance of a `Date`, `Time` or `DateTime`, in which case the relevant component will be extracted, or a numerical value. For example:
|
597
597
|
|
598
598
|
```erb
|
599
599
|
<%= select_year(2009) %>
|
@@ -623,7 +623,7 @@ Rails provides the usual pair of helpers: the barebones `file_field_tag` and the
|
|
623
623
|
|
624
624
|
### What Gets Uploaded
|
625
625
|
|
626
|
-
The object in the `params` hash is an instance of a subclass of `IO`. Depending on the size of the uploaded file it may in fact be a StringIO or an instance of `File` backed by a temporary file. In both cases the object will have an `original_filename` attribute containing the name the file had on the user's computer and a `content_type` attribute containing the MIME type of the uploaded file. The following snippet saves the uploaded content in `#{Rails.root}/public/uploads` under the same name as the original file (assuming the form was the one in the previous example).
|
626
|
+
The object in the `params` hash is an instance of a subclass of `IO`. Depending on the size of the uploaded file it may in fact be a `StringIO` or an instance of `File` backed by a temporary file. In both cases the object will have an `original_filename` attribute containing the name the file had on the user's computer and a `content_type` attribute containing the MIME type of the uploaded file. The following snippet saves the uploaded content in `#{Rails.root}/public/uploads` under the same name as the original file (assuming the form was the one in the previous example).
|
627
627
|
|
628
628
|
```ruby
|
629
629
|
def upload
|
@@ -645,7 +645,7 @@ Unlike other forms making an asynchronous file upload form is not as simple as p
|
|
645
645
|
Customizing Form Builders
|
646
646
|
-------------------------
|
647
647
|
|
648
|
-
As mentioned previously the object yielded by `form_for` and `fields_for` is an instance of `FormBuilder` (or a subclass thereof). Form builders encapsulate the notion of displaying form elements for a single object. While you can of course write helpers for your forms in the usual way, you can also subclass `FormBuilder` and add the helpers there. For example
|
648
|
+
As mentioned previously the object yielded by `form_for` and `fields_for` is an instance of `FormBuilder` (or a subclass thereof). Form builders encapsulate the notion of displaying form elements for a single object. While you can of course write helpers for your forms in the usual way, you can also subclass `FormBuilder` and add the helpers there. For example:
|
649
649
|
|
650
650
|
```erb
|
651
651
|
<%= form_for @person do |f| %>
|
@@ -684,12 +684,12 @@ If `f` is an instance of `FormBuilder` then this will render the `form` partial,
|
|
684
684
|
Understanding Parameter Naming Conventions
|
685
685
|
------------------------------------------
|
686
686
|
|
687
|
-
As you've seen in the previous sections, values from forms can be at the top level of the `params` hash or nested in another hash. For example in a standard `create`
|
687
|
+
As you've seen in the previous sections, values from forms can be at the top level of the `params` hash or nested in another hash. For example, in a standard `create`
|
688
688
|
action for a Person model, `params[:person]` would usually be a hash of all the attributes for the person to create. The `params` hash can also contain arrays, arrays of hashes and so on.
|
689
689
|
|
690
690
|
Fundamentally HTML forms don't know about any sort of structured data, all they generate is name-value pairs, where pairs are just plain strings. The arrays and hashes you see in your application are the result of some parameter naming conventions that Rails uses.
|
691
691
|
|
692
|
-
TIP: You may find you can try out examples in this section faster by using the console to directly invoke
|
692
|
+
TIP: You may find you can try out examples in this section faster by using the console to directly invoke Rack's parameter parser. For example,
|
693
693
|
|
694
694
|
```ruby
|
695
695
|
Rack::Utils.parse_query "name=fred&phone=0123456789"
|
@@ -698,7 +698,7 @@ Rack::Utils.parse_query "name=fred&phone=0123456789"
|
|
698
698
|
|
699
699
|
### Basic Structures
|
700
700
|
|
701
|
-
The two basic structures are arrays and hashes. Hashes mirror the syntax used for accessing the value in `params`. For example if a form contains
|
701
|
+
The two basic structures are arrays and hashes. Hashes mirror the syntax used for accessing the value in `params`. For example, if a form contains:
|
702
702
|
|
703
703
|
```html
|
704
704
|
<input id="person_name" name="person[name]" type="text" value="Henry"/>
|
@@ -712,7 +712,7 @@ the `params` hash will contain
|
|
712
712
|
|
713
713
|
and `params[:person][:name]` will retrieve the submitted value in the controller.
|
714
714
|
|
715
|
-
Hashes can be nested as many levels as required, for example
|
715
|
+
Hashes can be nested as many levels as required, for example:
|
716
716
|
|
717
717
|
```html
|
718
718
|
<input id="person_address_city" name="person[address][city]" type="text" value="New York"/>
|
@@ -724,7 +724,7 @@ will result in the `params` hash being
|
|
724
724
|
{'person' => {'address' => {'city' => 'New York'}}}
|
725
725
|
```
|
726
726
|
|
727
|
-
Normally Rails ignores duplicate parameter names. If the parameter name contains an empty set of square brackets [] then they will be accumulated in an array. If you wanted
|
727
|
+
Normally Rails ignores duplicate parameter names. If the parameter name contains an empty set of square brackets `[]` then they will be accumulated in an array. If you wanted users to be able to input multiple phone numbers, you could place this in the form:
|
728
728
|
|
729
729
|
```html
|
730
730
|
<input name="person[phone_number][]" type="text"/>
|
@@ -732,11 +732,11 @@ Normally Rails ignores duplicate parameter names. If the parameter name contains
|
|
732
732
|
<input name="person[phone_number][]" type="text"/>
|
733
733
|
```
|
734
734
|
|
735
|
-
This would result in `params[:person][:phone_number]` being an array.
|
735
|
+
This would result in `params[:person][:phone_number]` being an array containing the inputted phone numbers.
|
736
736
|
|
737
737
|
### Combining Them
|
738
738
|
|
739
|
-
We can mix and match these two concepts.
|
739
|
+
We can mix and match these two concepts. One element of a hash might be an array as in the previous example, or you can have an array of hashes. For example, a form might let you create any number of addresses by repeating the following form fragment
|
740
740
|
|
741
741
|
```html
|
742
742
|
<input name="addresses[][line1]" type="text"/>
|
@@ -746,7 +746,7 @@ We can mix and match these two concepts. For example, one element of a hash migh
|
|
746
746
|
|
747
747
|
This would result in `params[:addresses]` being an array of hashes with keys `line1`, `line2` and `city`. Rails decides to start accumulating values in a new hash whenever it encounters an input name that already exists in the current hash.
|
748
748
|
|
749
|
-
There's a restriction, however, while hashes can be nested arbitrarily, only one level of "arrayness" is allowed. Arrays can be
|
749
|
+
There's a restriction, however, while hashes can be nested arbitrarily, only one level of "arrayness" is allowed. Arrays can usually be replaced by hashes; for example, instead of having an array of model objects, one can have a hash of model objects keyed by their id, an array index or some other parameter.
|
750
750
|
|
751
751
|
WARNING: Array parameters do not play well with the `check_box` helper. According to the HTML specification unchecked checkboxes submit no value. However it is often convenient for a checkbox to always submit a value. The `check_box` helper fakes this by creating an auxiliary hidden input with the same name. If the checkbox is unchecked only the hidden input is submitted and if it is checked then both are submitted but the value submitted by the checkbox takes precedence. When working with array parameters this duplicate submission will confuse Rails since duplicate input names are how it decides when to start a new array element. It is preferable to either use `check_box_tag` or to use hashes instead of arrays.
|
752
752
|
|
@@ -856,7 +856,7 @@ Or if you don't want to render an `authenticity_token` field:
|
|
856
856
|
Building Complex Forms
|
857
857
|
----------------------
|
858
858
|
|
859
|
-
Many apps grow beyond simple forms editing a single object. For example when creating a `Person` you might want to allow the user to (on the same form) create multiple address records (home, work, etc.). When later editing that person the user should be able to add, remove or amend addresses as necessary.
|
859
|
+
Many apps grow beyond simple forms editing a single object. For example, when creating a `Person` you might want to allow the user to (on the same form) create multiple address records (home, work, etc.). When later editing that person the user should be able to add, remove or amend addresses as necessary.
|
860
860
|
|
861
861
|
### Configuring the Model
|
862
862
|
|
@@ -908,7 +908,7 @@ end
|
|
908
908
|
```
|
909
909
|
|
910
910
|
The `fields_for` yields a form builder. The parameters' name will be what
|
911
|
-
`accepts_nested_attributes_for` expects. For example when creating a user with
|
911
|
+
`accepts_nested_attributes_for` expects. For example, when creating a user with
|
912
912
|
2 addresses, the submitted parameters would look like:
|
913
913
|
|
914
914
|
```ruby
|
data/guides/source/generators.md
CHANGED
@@ -341,13 +341,17 @@ end
|
|
341
341
|
|
342
342
|
If you generate another resource, you can see that we get exactly the same result! This is useful if you want to customize your scaffold templates and/or layout by just creating `edit.html.erb`, `index.html.erb` and so on inside `lib/templates/erb/scaffold`.
|
343
343
|
|
344
|
-
|
344
|
+
Scaffold templates in Rails frequently use ERB tags; these tags need to be
|
345
|
+
escaped so that the generated output is valid ERB code.
|
346
|
+
|
347
|
+
For example, the following escaped ERB tag would be needed in the template
|
348
|
+
(note the extra `%`)...
|
345
349
|
|
346
350
|
```ruby
|
347
351
|
<%%= stylesheet_include_tag :application %>
|
348
352
|
```
|
349
353
|
|
350
|
-
|
354
|
+
...to generate the following output:
|
351
355
|
|
352
356
|
```ruby
|
353
357
|
<%= stylesheet_include_tag :application %>
|
@@ -1627,7 +1627,7 @@ controller. Again, we'll use the same generator we used before:
|
|
1627
1627
|
$ bin/rails generate controller Comments
|
1628
1628
|
```
|
1629
1629
|
|
1630
|
-
This creates
|
1630
|
+
This creates five files and one empty directory:
|
1631
1631
|
|
1632
1632
|
| File/Directory | Purpose |
|
1633
1633
|
| -------------------------------------------- | ---------------------------------------- |
|
data/guides/source/i18n.md
CHANGED
@@ -676,6 +676,22 @@ en:
|
|
676
676
|
<div><%= t('title.html') %></div>
|
677
677
|
```
|
678
678
|
|
679
|
+
Interpolation escapes as needed though. For example, given:
|
680
|
+
|
681
|
+
```yaml
|
682
|
+
en:
|
683
|
+
welcome_html: "<b>Welcome %{username}!</b>"
|
684
|
+
```
|
685
|
+
|
686
|
+
you can safely pass the username as set by the user:
|
687
|
+
|
688
|
+
```erb
|
689
|
+
<%# This is safe, it is going to be escaped if needed. %>
|
690
|
+
<%= t('welcome_html', username: @current_user.username %>
|
691
|
+
```
|
692
|
+
|
693
|
+
Safe strings on the other hand are interpolated verbatim.
|
694
|
+
|
679
695
|
NOTE: Automatic conversion to HTML safe translate text is only available from the `translate` view helper method.
|
680
696
|
|
681
697
|
![i18n demo html safe](images/i18n/demo_html_safe.png)
|
@@ -111,7 +111,6 @@ A standard Rails application depends on several gems, specifically:
|
|
111
111
|
* i18n
|
112
112
|
* mail
|
113
113
|
* mime-types
|
114
|
-
* polyglot
|
115
114
|
* rack
|
116
115
|
* rack-cache
|
117
116
|
* rack-mount
|
@@ -121,7 +120,6 @@ A standard Rails application depends on several gems, specifically:
|
|
121
120
|
* rake
|
122
121
|
* sqlite3
|
123
122
|
* thor
|
124
|
-
* treetop
|
125
123
|
* tzinfo
|
126
124
|
|
127
125
|
### `rails/commands.rb`
|
@@ -248,7 +248,8 @@ service requests that are expecting something other than proper HTML.
|
|
248
248
|
|
249
249
|
NOTE: By default, if you use the `:plain` option, the text is rendered without
|
250
250
|
using the current layout. If you want Rails to put the text into the current
|
251
|
-
layout, you need to add the `layout: true` option.
|
251
|
+
layout, you need to add the `layout: true` option and use the `.txt.erb`
|
252
|
+
extension for the layout file.
|
252
253
|
|
253
254
|
#### Rendering HTML
|
254
255
|
|
@@ -39,7 +39,10 @@ Only the latest release series will receive bug fixes. When enough bugs are
|
|
39
39
|
fixed and its deemed worthy to release a new gem, this is the branch it happens
|
40
40
|
from.
|
41
41
|
|
42
|
-
|
42
|
+
In special situations, where someone from the Core Team agrees to support more series,
|
43
|
+
they are included in the list of supported series.
|
44
|
+
|
45
|
+
**Currently included series:** `4.2.Z`, `4.1.Z` (Supported by Rafael França).
|
43
46
|
|
44
47
|
Security Issues
|
45
48
|
---------------
|
@@ -54,7 +57,7 @@ be built from 1.2.2, and then added to the end of 1-2-stable. This means that
|
|
54
57
|
security releases are easy to upgrade to if you're running the latest version
|
55
58
|
of Rails.
|
56
59
|
|
57
|
-
**Currently included series:** `4.
|
60
|
+
**Currently included series:** `4.2.Z`, `4.1.Z`.
|
58
61
|
|
59
62
|
Severe Security Issues
|
60
63
|
----------------------
|
@@ -63,7 +66,7 @@ For severe security issues we will provide new versions as above, and also the
|
|
63
66
|
last major release series will receive patches and new versions. The
|
64
67
|
classification of the security issue is judged by the core team.
|
65
68
|
|
66
|
-
**Currently included series:** `4.
|
69
|
+
**Currently included series:** `4.2.Z`, `4.1.Z`, `3.2.Z`.
|
67
70
|
|
68
71
|
Unsupported Release Series
|
69
72
|
--------------------------
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Rails
|
1
|
+
Rails Nested Model Forms
|
2
2
|
========================
|
3
3
|
|
4
4
|
Creating a form for a model _and_ its associations can become quite tedious. Therefore Rails provides helpers to assist in dealing with the complexities of generating these forms _and_ the required CRUD operations to create, update, and destroy associations.
|
@@ -54,6 +54,9 @@ class Person < ActiveRecord::Base
|
|
54
54
|
end
|
55
55
|
```
|
56
56
|
|
57
|
+
NOTE: For greater detail on associations see [Active Record Associations](association_basics.html).
|
58
|
+
For a complete reference on associations please visit the API documentation for [ActiveRecord::Associations::ClassMethods](http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html).
|
59
|
+
|
57
60
|
### Custom model
|
58
61
|
|
59
62
|
As you might have inflected from this explanation, you _don't_ necessarily need an ActiveRecord::Base model to use this functionality. The following examples are sufficient to enable the nested model form behavior:
|
data/guides/source/routing.md
CHANGED
@@ -756,7 +756,7 @@ get '*a/foo/*b', to: 'test#index'
|
|
756
756
|
|
757
757
|
would match `zoo/woo/foo/bar/baz` with `params[:a]` equals `'zoo/woo'`, and `params[:b]` equals `'bar/baz'`.
|
758
758
|
|
759
|
-
NOTE: By requesting `'/foo/bar.json'`, your `params[:pages]` will be
|
759
|
+
NOTE: By requesting `'/foo/bar.json'`, your `params[:pages]` will be equal to `'foo/bar'` with the request format of JSON. If you want the old 3.0.x behavior back, you could supply `format: false` like this:
|
760
760
|
|
761
761
|
```ruby
|
762
762
|
get '*pages', to: 'pages#show', format: false
|