Skip to content

Commit fdd203f

Browse files
committed
Merge remote branch 'docrails/master'
2 parents 315e895 + 158473f commit fdd203f

File tree

5 files changed

+42
-13
lines changed

5 files changed

+42
-13
lines changed

railties/guides/source/action_view_overview.textile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ Creates a scope around a specific model object like form_for, but doesn‘t crea
699699
First name: <%= person_form.text_field :first_name %>
700700
Last name : <%= person_form.text_field :last_name %>
701701

702-
<% fields_for @person.permission do |permission_fields| %>
702+
<%= fields_for @person.permission do |permission_fields| %>
703703
Admin? : <%= permission_fields.check_box :admin %>
704704
<% end %>
705705
<% end %>

railties/guides/source/active_support_core_extensions.textile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,39 @@ There's also the destructive version +String#squish!+.
12541254

12551255
NOTE: Defined in +active_support/core_ext/string/filters.rb+.
12561256

1257+
h4. +truncate+
1258+
1259+
The method +truncate+ returns a copy of its receiver truncated after a given +length+:
1260+
1261+
<ruby>
1262+
"Oh dear! Oh dear! I shall be late!".truncate(20)
1263+
# => "Oh dear! Oh dear!..."
1264+
</ruby>
1265+
1266+
Ellipsis can be customized with the +:omission+ option:
1267+
1268+
<ruby>
1269+
"Oh dear! Oh dear! I shall be late!".truncate(20, :omission => '&hellip;')
1270+
# => "Oh dear! Oh &hellip;"
1271+
</ruby>
1272+
1273+
Note in particular that truncation takes into account the length of the omission string.
1274+
1275+
Pass a +:separator+ to truncate the string at a natural break:
1276+
1277+
<ruby>
1278+
"Oh dear! Oh dear! I shall be late!".truncate(18)
1279+
# => "Oh dear! Oh dea..."
1280+
"Oh dear! Oh dear! I shall be late!".truncate(18, :separator => ' ')
1281+
# => "Oh dear! Oh..."
1282+
</ruby>
1283+
1284+
In the above example "dear" gets cut first, but then +:separator+ prevents it.
1285+
1286+
WARNING: The option +:separator+ can't be a regexp.
1287+
1288+
NOTE: Defined in +active_support/core_ext/string/filters.rb+.
1289+
12571290
h4. Key-based Interpolation
12581291

12591292
In Ruby 1.9 the <tt>%</tt> string operator supports key-based interpolation, both formatted and unformatted:

railties/guides/source/activerecord_validations_callbacks.textile

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -879,32 +879,28 @@ Here is a list with all the available Active Record callbacks, listed in the sam
879879
h4. Creating an Object
880880

881881
* +before_validation+
882-
* +before_validation_on_create+
883882
* +after_validation+
884-
* +after_validation_on_create+
885883
* +before_save+
884+
* +after_save+
886885
* +before_create+
887-
* INSERT OPERATION
886+
* +around_create+
888887
* +after_create+
889-
* +after_save+
890888

891889
h4. Updating an Object
892890

893891
* +before_validation+
894-
* +before_validation_on_update+
895892
* +after_validation+
896-
* +after_validation_on_update+
897893
* +before_save+
894+
* +after_save+
898895
* +before_update+
899-
* UPDATE OPERATION
896+
* +around_update+
900897
* +after_update+
901-
* +after_save+
902898

903899
h4. Destroying an Object
904900

905901
* +before_destroy+
906-
* DELETE OPERATION
907902
* +after_destroy+
903+
* +around_destroy+
908904

909905
WARNING. +after_save+ runs both on create and update, but always _after_ the more specific callbacks +after_create+ and +after_update+, no matter the order in which the macro calls were executed.
910906

railties/guides/source/getting_started.textile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ We also add a <tt>@post.tags.build</tt> at the top of this form, this is to make
13421342
Now create the folder <tt>app/views/tags</tt> and make a file in there called <tt>_form.html.erb</tt> which contains the form for the tag:
13431343

13441344
<erb>
1345-
<% form.fields_for :tags do |tag_form| %>
1345+
<%= form.fields_for :tags do |tag_form| %>
13461346
<div class="field">
13471347
<%= tag_form.label :name, 'Tag:' %>
13481348
<%= tag_form.text_field :name %>

railties/guides/source/nested_model_forms.textile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Now add a nested form for the +address+ association:
143143
<%= form_for @person do |f| %>
144144
<%= f.text_field :name %>
145145

146-
<% f.fields_for :address do |af| %>
146+
<%= f.fields_for :address do |af| %>
147147
<%= f.text_field :street %>
148148
<% end %>
149149
<% end %>
@@ -184,7 +184,7 @@ The form code for an association collection is pretty similar to that of a singl
184184
<%= form_for @person do |f| %>
185185
<%= f.text_field :name %>
186186

187-
<% f.fields_for :projects do |pf| %>
187+
<%= f.fields_for :projects do |pf| %>
188188
<%= f.text_field :name %>
189189
<% end %>
190190
<% end %>

0 commit comments

Comments
 (0)