aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute.rb1
-rw-r--r--guides/source/action_controller_overview.md2
-rw-r--r--guides/source/action_view_overview.md17
-rw-r--r--guides/source/active_record_querying.md2
-rw-r--r--guides/source/active_record_validations.md4
-rw-r--r--guides/source/active_support_instrumentation.md8
-rw-r--r--guides/source/association_basics.md18
-rw-r--r--guides/source/command_line.md19
-rw-r--r--guides/source/contributing_to_ruby_on_rails.md4
-rw-r--r--guides/source/getting_started.md2
-rw-r--r--guides/source/kindle/toc.html.erb2
-rw-r--r--guides/source/layout.html.erb14
-rw-r--r--guides/source/routing.md6
-rw-r--r--guides/source/upgrading_ruby_on_rails.md2
-rw-r--r--guides/source/working_with_javascript_in_rails.md4
-rw-r--r--railties/lib/rails/generators/rails/controller/USAGE1
16 files changed, 69 insertions, 37 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb
index 6fa9967a28..83038f9da5 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -70,7 +70,6 @@ class Class
# To opt out of both instance methods, pass <tt>instance_accessor: false</tt>.
def class_attribute(*attrs)
options = attrs.extract_options!
- # double assignment is used to avoid "assigned but unused variable" warning
instance_reader = options.fetch(:instance_accessor, true) && options.fetch(:instance_reader, true)
instance_writer = options.fetch(:instance_accessor, true) && options.fetch(:instance_writer, true)
instance_predicate = options.fetch(:instance_predicate, true)
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md
index 2701f5bb72..6a91418e1f 100644
--- a/guides/source/action_controller_overview.md
+++ b/guides/source/action_controller_overview.md
@@ -129,7 +129,7 @@ Note that the `params` hash is actually an instance of `ActiveSupport::HashWithI
### JSON parameters
-If you're writing a web service application, you might find yourself more comfortable accepting parameters in JSON format. Rails will automatically convert your parameters into the `params` hash, which you can access as you would normally.
+If you're writing a web service application, you might find yourself more comfortable accepting parameters in JSON format. If the "Content-Type" header of your request is set to "application/json", Rails will automatically convert your parameters into the `params` hash, which you can access as you would normally.
So for example, if you are sending this JSON content:
diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md
index 187c910e37..b3fc61f386 100644
--- a/guides/source/action_view_overview.md
+++ b/guides/source/action_view_overview.md
@@ -1230,6 +1230,14 @@ Return select and option tags for the given object and method, using `time_zone_
time_zone_select( "user", "time_zone")
```
+#### date_field
+
+Returns an input tag of the "date" type tailored for accessing a specified attribute.
+
+```ruby
+date_field("user", "dob")
+```
+
### FormTagHelper
Provides a number of methods for creating form tags that doesn't rely on an Active Record object assigned to the template like FormHelper does. Instead, you provide the names and values manually.
@@ -1364,6 +1372,15 @@ text_field_tag 'name'
# => <input id="name" name="name" type="text" />
```
+#### date_field_tag
+
+Creates a standard input field of date type.
+
+```ruby
+date_field_tag "dob"
+# => <input id="dob" name="dob" type="date" />
+```
+
### JavaScriptHelper
Provides functionality for working with JavaScript in your views.
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 2555927d15..407e779f9f 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -58,6 +58,7 @@ The methods are:
* `bind`
* `create_with`
+* `distinct`
* `eager_load`
* `extending`
* `from`
@@ -76,7 +77,6 @@ The methods are:
* `reorder`
* `reverse_order`
* `select`
-* `distinct`
* `uniq`
* `where`
diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md
index 37790c62b1..3bfc600e7c 100644
--- a/guides/source/active_record_validations.md
+++ b/guides/source/active_record_validations.md
@@ -120,8 +120,8 @@ database only if the object is valid:
* `update!`
The bang versions (e.g. `save!`) raise an exception if the record is invalid.
-The non-bang versions don't: `save` and `update` return `false`,
-`create` and `update` just return the objects.
+The non-bang versions don't, `save` and `update` return `false`,
+`create` just return the objects.
### Skipping Validations
diff --git a/guides/source/active_support_instrumentation.md b/guides/source/active_support_instrumentation.md
index 38dbfd3152..969596f470 100644
--- a/guides/source/active_support_instrumentation.md
+++ b/guides/source/active_support_instrumentation.md
@@ -39,7 +39,7 @@ Action Controller
```ruby
{
- key: 'posts/1-dasboard-view'
+ key: 'posts/1-dashboard-view'
}
```
@@ -51,7 +51,7 @@ Action Controller
```ruby
{
- key: 'posts/1-dasboard-view'
+ key: 'posts/1-dashboard-view'
}
```
@@ -63,7 +63,7 @@ Action Controller
```ruby
{
- key: 'posts/1-dasboard-view'
+ key: 'posts/1-dashboard-view'
}
```
@@ -75,7 +75,7 @@ Action Controller
```ruby
{
- key: 'posts/1-dasboard-view'
+ key: 'posts/1-dashboard-view'
}
```
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md
index d7277b487f..c0e584a1c7 100644
--- a/guides/source/association_basics.md
+++ b/guides/source/association_basics.md
@@ -781,7 +781,7 @@ The `create_association` method returns a new object of the associated type. Thi
##### `create_association!(attributes = {})`
-Does the same as <tt>create_association</tt> above, but raises <tt>ActiveRecord::RecordInvalid</tt> if the record is invalid.
+Does the same as `create_association` above, but raises `ActiveRecord::RecordInvalid` if the record is invalid.
#### Options for `belongs_to`
@@ -1083,7 +1083,7 @@ The `create_association` method returns a new object of the associated type. Thi
##### `create_association!(attributes = {})`
-Does the same as <tt>create_association</tt> above, but raises <tt>ActiveRecord::RecordInvalid</tt> if the record is invalid.
+Does the same as `create_association` above, but raises `ActiveRecord::RecordInvalid` if the record is invalid.
#### Options for `has_one`
@@ -1443,7 +1443,7 @@ The `collection.create` method returns a new object of the associated type. This
##### `collection.create!(attributes = {})`
-Does the same as <tt>collection.create</tt> above, but raises <tt>ActiveRecord::RecordInvalid</tt> if the record is invalid.
+Does the same as `collection.create` above, but raises `ActiveRecord::RecordInvalid` if the record is invalid.
#### Options for `has_many`
@@ -1736,15 +1736,15 @@ If you want to make sure that, upon insertion, all of the records in the
persisted association are distinct (so that you can be sure that when you
inspect the association that you will never find duplicate records), you should
add a unique index on the table itself. For example, if you have a table named
-``person_posts`` and you want to make sure all the posts are unique, you could
+`person_posts` and you want to make sure all the posts are unique, you could
add the following in a migration:
```ruby
-add_index :person_posts, :post, :unique => true
+add_index :person_posts, :post, unique: true
```
-Note that checking for uniqueness using something like ``include?`` is subject
-to race conditions. Do not attempt to use ``include?`` to enforce distinctness
+Note that checking for uniqueness using something like `include?` is subject
+to race conditions. Do not attempt to use `include?` to enforce distinctness
in an association. For instance, using the post example from above, the
following code would be racy because multiple users could be attempting this
at the same time:
@@ -1936,7 +1936,7 @@ The `collection.create` method returns a new object of the associated type. This
##### `collection.create!(attributes = {})`
-Does the same as <tt>collection.create</tt>, but raises <tt>ActiveRecord::RecordInvalid</tt> if the record is invalid.
+Does the same as `collection.create`, but raises `ActiveRecord::RecordInvalid` if the record is invalid.
#### Options for `has_and_belongs_to_many`
@@ -2199,4 +2199,4 @@ Extensions can refer to the internals of the association proxy using these three
* `proxy_association.owner` returns the object that the association is a part of.
* `proxy_association.reflection` returns the reflection object that describes the association.
-* `proxy_association.target` returns the associated object for `belongs_to` or `has_one`, or the collection of associated objects for `has_many` or `has_and_belongs_to_many`. \ No newline at end of file
+* `proxy_association.target` returns the associated object for `belongs_to` or `has_one`, or the collection of associated objects for `has_many` or `has_and_belongs_to_many`.
diff --git a/guides/source/command_line.md b/guides/source/command_line.md
index e00e70576f..218b4dd39a 100644
--- a/guides/source/command_line.md
+++ b/guides/source/command_line.md
@@ -27,6 +27,8 @@ There are a few commands that are absolutely critical to your everyday usage of
* `rails dbconsole`
* `rails new app_name`
+All commands can run with ```-h or --help``` to list more information.
+
Let's create a simple Rails application to step through each of these commands in context.
### `rails new`
@@ -348,6 +350,9 @@ Rake is Ruby Make, a standalone Ruby utility that replaces the Unix utility 'mak
You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing `rake --tasks`. Each task has a description, and should help you find the thing you need.
+To get the full backtrace for running rake task you can pass the option
+```--trace``` to command line, for example ```rake db:create --trace```.
+
```bash
$ rake --tasks
rake about # List versions of all Rails frameworks and the environment
@@ -361,6 +366,7 @@ rake middleware # Prints out your Rack middleware stack
rake tmp:clear # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)
rake tmp:create # Creates tmp directories for sessions, cache, sockets, and pids
```
+INFO: You can also use ```rake -T``` to get the list of tasks.
### `about`
@@ -372,12 +378,12 @@ About your application's environment
Ruby version 1.9.3 (x86_64-linux)
RubyGems version 1.3.6
Rack version 1.3
-Rails version 4.0.0.beta
+Rails version 4.0.0
JavaScript Runtime Node.js (V8)
-Active Record version 4.0.0.beta
-Action Pack version 4.0.0.beta
-Action Mailer version 4.0.0.beta
-Active Support version 4.0.0.beta
+Active Record version 4.0.0
+Action Pack version 4.0.0
+Action Mailer version 4.0.0
+Active Support version 4.0.0
Middleware ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::EncryptedCookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag
Application root /home/foobar/commandsapp
Environment development
@@ -468,12 +474,13 @@ Rails comes with a test suite called `Test::Unit`. Rails owes its stability to t
The `Rails.root/tmp` directory is, like the *nix /tmp directory, the holding place for temporary files like sessions (if you're using a file store for files), process id files, and cached actions.
-The `tmp:` namespaced tasks will help you clear the `Rails.root/tmp` directory:
+The `tmp:` namespaced tasks will help you clear and create the `Rails.root/tmp` directory:
* `rake tmp:cache:clear` clears `tmp/cache`.
* `rake tmp:sessions:clear` clears `tmp/sessions`.
* `rake tmp:sockets:clear` clears `tmp/sockets`.
* `rake tmp:clear` clears all the three: cache, sessions and sockets.
+* `rake tmp:create` creates tmp directories for sessions, cache, sockets, and pids.
### Miscellaneous
diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md
index 0bfa646b81..b9f42fa51b 100644
--- a/guides/source/contributing_to_ruby_on_rails.md
+++ b/guides/source/contributing_to_ruby_on_rails.md
@@ -184,7 +184,9 @@ Ruby on Rails has two main sets of documentation: the guides help you in learnin
You can help improve the Rails guides by making them more coherent, consistent or readable, adding missing information, correcting factual errors, fixing typos, or bringing it up to date with the latest edge Rails. To get involved in the translation of Rails guides, please see [Translating Rails Guides](https://wiki.github.com/rails/docrails/translating-rails-guides).
-If you're confident about your changes, you can push them directly yourself via [docrails](https://github.com/rails/docrails). Docrails is a branch with an **open commit policy** and public write access. Commits to docrails are still reviewed, but this happens after they are pushed. Docrails is merged with master regularly, so you are effectively editing the Ruby on Rails documentation.
+You can either ask for commit bit if you'd like to contribute to [Docrails](http://github.com/rails/docrails) regularly (Please contact anyone from [the core team](http://rubyonrails.org/core)), or else open a pull request to [Rails](http://github.com/rails/rails) itself.
+
+Docrails is merged with master regularly, so you are effectively editing the Ruby on Rails documentation.
If you are unsure of the documentation changes, you can create an issue in the [Rails](https://github.com/rails/rails/issues) issues tracker on GitHub.
diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md
index a773519bba..455907535b 100644
--- a/guides/source/getting_started.md
+++ b/guides/source/getting_started.md
@@ -1659,7 +1659,7 @@ Two very common sources of data that are not UTF-8:
in the browser. This also applies to your i18n translation files.
Most editors that do not already default to UTF-8 (such as some versions of
Dreamweaver) offer a way to change the default to UTF-8. Do so.
-* Your database. Rails defaults to converting data from your database into UTF-8 at
+* Your database: Rails defaults to converting data from your database into UTF-8 at
the boundary. However, if your database is not using UTF-8 internally, it may not
be able to store all characters that your users enter. For instance, if your database
is using Latin-1 internally, and your user enters a Russian, Hebrew, or Japanese
diff --git a/guides/source/kindle/toc.html.erb b/guides/source/kindle/toc.html.erb
index e013797dee..f310edd3a1 100644
--- a/guides/source/kindle/toc.html.erb
+++ b/guides/source/kindle/toc.html.erb
@@ -20,5 +20,5 @@ Ruby on Rails Guides
<ul>
<li><a href="credits.html">Credits</a></li>
<li><a href="copyright.html">Copyright &amp; License</a></li>
-<ul>
+</ul>
</div>
diff --git a/guides/source/layout.html.erb b/guides/source/layout.html.erb
index 1dcf383b92..c737a0e9dc 100644
--- a/guides/source/layout.html.erb
+++ b/guides/source/layout.html.erb
@@ -101,12 +101,14 @@
You're encouraged to help improve the quality of this guide.
</p>
<p>
- If you see any typos or factual errors you are confident to
- patch, please clone the <%= link_to 'rails', 'https://github.com/rails/rails' %>
- repository and open a new pull request. You can also ask for commit rights on
- <%= link_to 'docrails', 'https://github.com/rails/docrails' %> if you plan to submit
- several patches. Commits are reviewed, but that happens after you've submitted your
- contribution. This repository is cross-merged with master periodically.
+ If you see any typos or factual errors that you are confident to fix,
+ you can push the fix to <%= link_to 'docrails', 'https://github.com/rails/docrails' %> (Ask
+ the <%= link_to 'Rails core team', 'http://rubyonrails.org/core' %> for push access).
+ If you choose to open a pull request, please do it in <%= link_to 'Rails', 'https://github.com/rails/rails' %>
+ and not in the <%= link_to 'docrails', 'https://github.com/rails/docrails' %> repository.
+ Commits made to docrails are still reviewed, but that happens after you've submitted your
+ contribution. <%= link_to 'docrails', 'https://github.com/rails/docrails' %> is
+ cross-merged with master periodically.
</p>
<p>
You may also find incomplete content, or stuff that is not up to date.
diff --git a/guides/source/routing.md b/guides/source/routing.md
index 592429952a..76c4c25108 100644
--- a/guides/source/routing.md
+++ b/guides/source/routing.md
@@ -171,6 +171,12 @@ A singular resourceful route generates these helpers:
As with plural resources, the same helpers ending in `_url` will also include the host, port and path prefix.
+WARNING: A [long-standing bug](https://github.com/rails/rails/issues/1769) prevents `form_for` from working automatically with singular resources. As a workaround, specify the URL for the form directly, like so:
+
+```ruby
+form_for @geocoder, url: geocoder_path do |f|
+```
+
### Controller Namespaces and Routing
You may wish to organize groups of controllers under a namespace. Most commonly, you might group a number of administrative controllers under an `Admin::` namespace. You would place these controllers under the `app/controllers/admin` directory, and you can group them together in your router:
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md
index 35a9617b80..e7e28e21a3 100644
--- a/guides/source/upgrading_ruby_on_rails.md
+++ b/guides/source/upgrading_ruby_on_rails.md
@@ -61,7 +61,7 @@ end
```ruby
class UsersController < ApplicationController
def update_name
- # Change needed; form_for will try to use a non-existant PATCH route.
+ # Change needed; form_for will try to use a non-existent PATCH route.
end
end
```
diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md
index 22a59cdfec..bd0c796673 100644
--- a/guides/source/working_with_javascript_in_rails.md
+++ b/guides/source/working_with_javascript_in_rails.md
@@ -278,9 +278,7 @@ The index view (`app/views/users/index.html.erb`) contains:
<b>Users</b>
<ul id="users">
-<% @users.each do |user| %>
- <%= render user %>
-<% end %>
+<%= render @users %>
</ul>
<br>
diff --git a/railties/lib/rails/generators/rails/controller/USAGE b/railties/lib/rails/generators/rails/controller/USAGE
index 64239ad599..de33900e0a 100644
--- a/railties/lib/rails/generators/rails/controller/USAGE
+++ b/railties/lib/rails/generators/rails/controller/USAGE
@@ -16,3 +16,4 @@ Example:
Test: test/controllers/credit_cards_controller_test.rb
Views: app/views/credit_cards/debit.html.erb [...]
Helper: app/helpers/credit_cards_helper.rb
+ Test: test/helpers/credit_cards_helper_test.rb