Skip to content

Commit 0a33fcd

Browse files
committed
Merge branch 'master' of github.com:lifo/docrails
2 parents 1233fc6 + 7297980 commit 0a33fcd

32 files changed

+196
-172
lines changed

actionpack/lib/action_view/helpers/form_helper.rb

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,8 @@ def label(object_name, method, content_or_options = nil, options = nil, &block)
775775
# text_field(:post, :title, class: "create_input")
776776
# # => <input type="text" id="post_title" name="post[title]" value="#{@post.title}" class="create_input" />
777777
#
778-
# text_field(:session, :user, onchange: "if $('session[user]').value == 'admin' { alert('Your login can not be admin!'); }")
779-
# # => <input type="text" id="session_user" name="session[user]" value="#{@session.user}" onchange = "if $('session[user]').value == 'admin' { alert('Your login can not be admin!'); }"/>
778+
# text_field(:session, :user, onchange: "if $('#session_user').value == 'admin' { alert('Your login can not be admin!'); }")
779+
# # => <input type="text" id="session_user" name="session[user]" value="#{@session.user}" onchange = "if $('#session_user').value == 'admin' { alert('Your login can not be admin!'); }"/>
780780
#
781781
# text_field(:snippet, :code, size: 20, class: 'code_input')
782782
# # => <input type="text" id="snippet_code" name="snippet[code]" size="20" value="#{@snippet.code}" class="code_input" />
@@ -830,13 +830,25 @@ def hidden_field(object_name, method, options = {})
830830
#
831831
# Using this method inside a +form_for+ block will set the enclosing form's encoding to <tt>multipart/form-data</tt>.
832832
#
833+
# ==== Options
834+
# * Creates standard HTML attributes for the tag.
835+
# * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
836+
# * <tt>:multiple</tt> - If set to true, *in most updated browsers* the user will be allowed to select multiple files.
837+
# * <tt>:accept</tt> - If set to one or multiple mime-types, the user will be suggested a filter when choosing a file. You still need to set up model validations.
838+
#
833839
# ==== Examples
834840
# file_field(:user, :avatar)
835841
# # => <input type="file" id="user_avatar" name="user[avatar]" />
836842
#
843+
# file_field(:post, :image, :multiple => true)
844+
# # => <input type="file" id="post_image" name="post[image]" multiple="true" />
845+
#
837846
# file_field(:post, :attached, accept: 'text/html')
838847
# # => <input accept="text/html" type="file" id="post_attached" name="post[attached]" />
839848
#
849+
# file_field(:post, :image, accept: 'image/png,image/gif,image/jpeg')
850+
# # => <input type="file" id="post_image" name="post[image]" accept="image/png,image/gif,image/jpeg" />
851+
#
840852
# file_field(:attachment, :file, class: 'file_input')
841853
# # => <input type="file" id="attachment_file" name="attachment[file]" class="file_input" />
842854
def file_field(object_name, method, options = {})
@@ -1214,6 +1226,10 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
12141226
RUBY_EVAL
12151227
end
12161228

1229+
# Instructions for this +method+ can be found in this documentation.
1230+
# For reusability and delegation reasons, various +methods+ have equal names.
1231+
# Please, look up the next +method+ with this name
1232+
#
12171233
def fields_for(record_name, record_object = nil, fields_options = {}, &block)
12181234
fields_options, record_object = record_object, nil if record_object.is_a?(Hash) && record_object.extractable_options?
12191235
fields_options[:builder] ||= options[:builder]
@@ -1243,23 +1259,43 @@ def fields_for(record_name, record_object = nil, fields_options = {}, &block)
12431259
@template.fields_for(record_name, record_object, fields_options, &block)
12441260
end
12451261

1262+
# Instructions for this +method+ can be found in this documentation.
1263+
# For reusability and delegation reasons, various +methods+ have equal names.
1264+
# Please, look up the next +method+ with this name
1265+
#
12461266
def label(method, text = nil, options = {}, &block)
12471267
@template.label(@object_name, method, text, objectify_options(options), &block)
12481268
end
12491269

1270+
# Instructions for this +method+ can be found in this documentation.
1271+
# For reusability and delegation reasons, various +methods+ have equal names.
1272+
# Please, look up the next +method+ with this name
1273+
#
12501274
def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
12511275
@template.check_box(@object_name, method, objectify_options(options), checked_value, unchecked_value)
12521276
end
12531277

1278+
# Instructions for this +method+ can be found in this documentation.
1279+
# For reusability and delegation reasons, various +methods+ have equal names.
1280+
# Please, look up the next +method+ with this name
1281+
#
12541282
def radio_button(method, tag_value, options = {})
12551283
@template.radio_button(@object_name, method, tag_value, objectify_options(options))
12561284
end
12571285

1286+
# Instructions for this +method+ can be found in this documentation.
1287+
# For reusability and delegation reasons, various +methods+ have equal names.
1288+
# Please, look up the next +method+ with this name
1289+
#
12581290
def hidden_field(method, options = {})
12591291
@emitted_hidden_id = true if method == :id
12601292
@template.hidden_field(@object_name, method, objectify_options(options))
12611293
end
12621294

1295+
# Instructions for this +method+ can be found in this documentation.
1296+
# For reusability and delegation reasons, various +methods+ have equal names.
1297+
# Please, look up the next +method+ with this name
1298+
#
12631299
def file_field(method, options = {})
12641300
self.multipart = true
12651301
@template.file_field(@object_name, method, objectify_options(options))

actionpack/lib/action_view/helpers/form_tag_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ def hidden_field_tag(name, value = nil, options = {})
233233
# ==== Options
234234
# * Creates standard HTML attributes for the tag.
235235
# * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
236+
# * <tt>:multiple</tt> - If set to true, *in most updated browsers* the user will be allowed to select multiple files.
237+
# * <tt>:accept</tt> - If set to one or multiple mime-types, the user will be suggested a filter when choosing a file. You still need to set up model validations.
236238
#
237239
# ==== Examples
238240
# file_field_tag 'attachment'

activesupport/lib/active_support/deprecation/proxy_wrappers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def method_missing(called, *args, &block)
3030
# @old_object = DeprecatedObjectProxy.new(Object.new, "Don't use this object anymore!")
3131
# @old_object = DeprecatedObjectProxy.new(Object.new, "Don't use this object anymore!", deprecator_instance)
3232
#
33-
# When someone execute any method expect +inspect+ on proxy object this will
33+
# When someone executes any method except +inspect+ on proxy object this will
3434
# trigger +warn+ method on +deprecator_instance+.
3535
#
3636
# Default deprecator is <tt>ActiveSupport::Deprecation</tt>

guides/source/action_controller_overview.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ In this guide you will learn how controllers work and how they fit into the requ
55

66
After reading this guide, you will know:
77

8-
* Follow the flow of a request through a controller.
9-
* Understand why and how to store data in the session or cookies.
10-
* Work with filters to execute code during request processing.
11-
* Use Action Controller's built-in HTTP authentication.
12-
* Stream data directly to the user's browser.
13-
* Filter sensitive parameters so they do not appear in the application's log.
14-
* Deal with exceptions that may be raised during request processing.
8+
* How to follow the flow of a request through a controller.
9+
* Why and how to store data in the session or cookies.
10+
* How to work with filters to execute code during request processing.
11+
* How to use Action Controller's built-in HTTP authentication.
12+
* How to stream data directly to the user's browser.
13+
* How to filter sensitive parameters so they do not appear in the application's log.
14+
* How to deal with exceptions that may be raised during request processing.
1515

1616
--------------------------------------------------------------------------------
1717

@@ -849,15 +849,15 @@ NOTE: Certain exceptions are only rescuable from the `ApplicationController` cla
849849
Force HTTPS protocol
850850
--------------------
851851

852-
Sometime you might want to force a particular controller to only be accessible via an HTTPS protocol for security reasons. Since Rails 3.1 you can now use the `force_ssl` method in your controller to enforce that:
852+
Sometime you might want to force a particular controller to only be accessible via an HTTPS protocol for security reasons. You can use the `force_ssl` method in your controller to enforce that:
853853

854854
```ruby
855855
class DinnerController
856856
force_ssl
857857
end
858858
```
859859

860-
Just like the filter, you could also passing `:only` and `:except` to enforce the secure connection only to specific actions:
860+
Just like the filter, you could also pass `:only` and `:except` to enforce the secure connection only to specific actions:
861861

862862
```ruby
863863
class DinnerController

guides/source/action_mailer_basics.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ This guide should provide you with all you need to get started in sending and re
55

66
After reading this guide, you will know:
77

8+
* How to send and receive email within a Rails application.
9+
* How to generate and edit an Action Mailer class and mailer view.
10+
* How to configure Action Mailer for your environment.
11+
* How to test your Action Mailer classes.
812
--------------------------------------------------------------------------------
913

1014
Introduction
@@ -105,7 +109,7 @@ When you call the `mail` method now, Action Mailer will detect the two templates
105109

106110
#### Wire It Up So That the System Sends the Email When a User Signs Up
107111

108-
There are several ways to do this, some people create Rails Observers to fire off emails, others do it inside of the User Model. However, in Rails 3, mailers are really just another way to render a view. Instead of rendering a view and sending out the HTTP protocol, they are just sending it out through the Email protocols instead. Due to this, it makes sense to just have your controller tell the mailer to send an email when a user is successfully created.
112+
There are several ways to do this, some people create Rails Observers to fire off emails, others do it inside of the User Model. However, mailers are really just another way to render a view. Instead of rendering a view and sending out the HTTP protocol, they are just sending it out through the Email protocols instead. Due to this, it makes sense to just have your controller tell the mailer to send an email when a user is successfully created.
109113

110114
Setting this up is painfully simple.
111115

@@ -145,10 +149,6 @@ This provides a much simpler implementation that does not require the registerin
145149

146150
The method `welcome_email` returns a `Mail::Message` object which can then just be told `deliver` to send itself out.
147151

148-
NOTE: In previous versions of Rails, you would call `deliver_welcome_email` or `create_welcome_email`. This has been deprecated in Rails 3.0 in favour of just calling the method name itself.
149-
150-
WARNING: Sending out an email should only take a fraction of a second. If you are planning on sending out many emails, or you have a slow domain resolution service, you might want to investigate using a background process like Delayed Job.
151-
152152
### Auto encoding header values
153153

154154
Action Mailer now handles the auto encoding of multibyte characters inside of headers and bodies.

guides/source/action_view_overview.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,10 +1263,8 @@ Creates a field set for grouping HTML form elements.
12631263

12641264
Creates a file upload field.
12651265

1266-
Prior to Rails 3.1, if you are using file uploads, then you will need to set the multipart option for the form tag. Rails 3.1+ does this automatically.
1267-
12681266
```html+erb
1269-
<%= form_tag {action: "post"}, {multipart: true} do %>
1267+
<%= form_tag {action: "post"} do %>
12701268
<label for="file">File to Upload</label> <%= file_field_tag "file" %>
12711269
<%= submit_tag %>
12721270
<% end %>

guides/source/active_record_callbacks.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Active Record Callbacks
44
This guide teaches you how to hook into the life cycle of your Active Record
55
objects.
66

7-
After reading this guide and trying out the presented concepts, we hope that you'll be able to:
7+
After reading this guide, you will know:
88

9-
* Understand the life cycle of Active Record objects
10-
* Create callback methods that respond to events in the object life cycle
11-
* Create special classes that encapsulate common behavior for your callbacks
9+
* The life cycle of Active Record objects.
10+
* How to create callback methods that respond to events in the object life cycle.
11+
* How to create special classes that encapsulate common behavior for your callbacks.
1212

1313
--------------------------------------------------------------------------------
1414

guides/source/active_record_querying.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ This guide covers different ways to retrieve data from the database using Active
55

66
After reading this guide, you will know:
77

8-
* Find records using a variety of methods and conditions.
9-
* Specify the order, retrieved attributes, grouping, and other properties of the found records.
10-
* Use eager loading to reduce the number of database queries needed for data retrieval.
11-
* Use dynamic finders methods.
12-
* Check for the existence of particular records.
13-
* Perform various calculations on Active Record models.
14-
* Run EXPLAIN on relations.
8+
* How to find records using a variety of methods and conditions.
9+
* How to specify the order, retrieved attributes, grouping, and other properties of the found records.
10+
* How to use eager loading to reduce the number of database queries needed for data retrieval.
11+
* How to use dynamic finders methods.
12+
* How to check for the existence of particular records.
13+
* How to perform various calculations on Active Record models.
14+
* How to run EXPLAIN on relations.
1515

1616
--------------------------------------------------------------------------------
1717

@@ -1204,7 +1204,7 @@ class Client < ActiveRecord::Base
12041204
end
12051205
```
12061206

1207-
### Removing all scoping
1207+
### Removing All Scoping
12081208

12091209
If we wish to remove scoping for any reason we can use the `unscoped` method. This is
12101210
especially useful if a `default_scope` is specified in the model and should not be
@@ -1236,9 +1236,7 @@ You can specify an exclamation point (`!`) on the end of the dynamic finders to
12361236

12371237
If you want to find both by name and locked, you can chain these finders together by simply typing "`and`" between the fields. For example, `Client.find_by_first_name_and_locked("Ryan", true)`.
12381238

1239-
WARNING: Up to and including Rails 3.1, when the number of arguments passed to a dynamic finder method is lesser than the number of fields, say `Client.find_by_name_and_locked("Ryan")`, the behavior is to pass `nil` as the missing argument. This is **unintentional** and this behavior will be changed in Rails 3.2 to throw an `ArgumentError`.
1240-
1241-
Find or build a new object
1239+
Find or Build a New Object
12421240
--------------------------
12431241

12441242
It's common that you need to find a record or create it if it doesn't exist. You can do that with the `find_or_create_by` and `find_or_create_by!` methods.

guides/source/active_record_validations.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ the database using Active Record's validations feature.
66

77
After reading this guide, you will know:
88

9-
* Use the built-in Active Record validation helpers
10-
* Create your own custom validation methods
11-
* Work with the error messages generated by the validation process
9+
* How to use the built-in Active Record validation helpers.
10+
* How to create your own custom validation methods.
11+
* How to work with the error messages generated by the validation process.
1212

1313
--------------------------------------------------------------------------------
1414

@@ -779,7 +779,7 @@ class Account < ActiveRecord::Base
779779
end
780780
```
781781

782-
### Grouping conditional validations
782+
### Grouping Conditional validations
783783

784784
Sometimes it is useful to have multiple validations use one condition, it can
785785
be easily achieved using `with_options`.
@@ -796,7 +796,7 @@ end
796796
All validations inside of `with_options` block will have automatically passed
797797
the condition `if: :is_admin?`
798798

799-
### Combining validation conditions
799+
### Combining Validation Conditions
800800

801801
On the other hand, when multiple conditions define whether or not a validation
802802
should happen, an `Array` can be used. Moreover, you can apply both `:if` and

guides/source/active_support_core_extensions.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ It offers a richer bottom-line at the language level, targeted both at the devel
77

88
After reading this guide, you will know:
99

10+
* What Core Extensions are.
11+
* How to load all extensions.
12+
* How to cherry-pick just the extensions you want.
13+
* What extensions ActiveSupport provides.
14+
1015
--------------------------------------------------------------------------------
1116

1217
How to Load Core Extensions
@@ -1120,8 +1125,6 @@ C.subclasses # => [B, D]
11201125

11211126
The order in which these classes are returned is unspecified.
11221127

1123-
WARNING: This method is redefined in some Rails core classes but should be all compatible in Rails 3.1.
1124-
11251128
NOTE: Defined in `active_support/core_ext/class/subclasses.rb`.
11261129

11271130
#### `descendants`
@@ -1157,7 +1160,7 @@ Inserting data into HTML templates needs extra care. For example, you can't just
11571160

11581161
#### Safe Strings
11591162

1160-
Active Support has the concept of <i>(html) safe</i> strings since Rails 3. A safe string is one that is marked as being insertable into HTML as is. It is trusted, no matter whether it has been escaped or not.
1163+
Active Support has the concept of <i>(html) safe</i> strings. A safe string is one that is marked as being insertable into HTML as is. It is trusted, no matter whether it has been escaped or not.
11611164

11621165
Strings are considered to be <i>unsafe</i> by default:
11631166

@@ -1194,10 +1197,10 @@ Safe arguments are directly appended:
11941197
"".html_safe + "<".html_safe # => "<"
11951198
```
11961199

1197-
These methods should not be used in ordinary views. In Rails 3 unsafe values are automatically escaped:
1200+
These methods should not be used in ordinary views. Unsafe values are automatically escaped:
11981201

11991202
```erb
1200-
<%= @review.title %> <%# fine in Rails 3, escaped if needed %>
1203+
<%= @review.title %> <%# fine, escaped if needed %>
12011204
```
12021205

12031206
To insert something verbatim use the `raw` helper rather than calling `html_safe`:

guides/source/api_documentation_guidelines.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ This guide documents the Ruby on Rails API documentation guidelines.
55

66
After reading this guide, you will know:
77

8+
* How to write effective prose for documentation purposes.
9+
* Style guidelines for documenting different kinds of Ruby code.
10+
811
--------------------------------------------------------------------------------
912

1013
RDoc

0 commit comments

Comments
 (0)