Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/lifo/docrails
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Mar 14, 2011
2 parents dfa9e28 + a0826cc commit 21b12d8
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 38 deletions.
1 change: 1 addition & 0 deletions Rakefile
Expand Up @@ -85,6 +85,7 @@ RDoc::Task.new do |rdoc|
rdoc.rdoc_files.include('actionmailer/README.rdoc')
rdoc.rdoc_files.include('actionmailer/CHANGELOG')
rdoc.rdoc_files.include('actionmailer/lib/action_mailer/base.rb')
rdoc.rdoc_files.include('actionmailer/lib/action_mailer/mail_helper.rb')
rdoc.rdoc_files.exclude('actionmailer/lib/action_mailer/vendor/*')

rdoc.rdoc_files.include('activesupport/README.rdoc')
Expand Down
8 changes: 4 additions & 4 deletions actionpack/lib/abstract_controller/view_paths.rb
Expand Up @@ -36,7 +36,7 @@ module ClassMethods
# ==== Parameters
# * <tt>path</tt> - If a String is provided, it gets converted into
# the default view path. You may also provide a custom view path
# (see ActionView::ViewPathSet for more information)
# (see ActionView::PathSet for more information)
def append_view_path(path)
self.view_paths = view_paths.dup + Array(path)
end
Expand All @@ -46,7 +46,7 @@ def append_view_path(path)
# ==== Parameters
# * <tt>path</tt> - If a String is provided, it gets converted into
# the default view path. You may also provide a custom view path
# (see ActionView::ViewPathSet for more information)
# (see ActionView::PathSet for more information)
def prepend_view_path(path)
self.view_paths = Array(path) + view_paths.dup
end
Expand All @@ -59,8 +59,8 @@ def view_paths
# Set the view paths.
#
# ==== Parameters
# * <tt>paths</tt> - If a ViewPathSet is provided, use that;
# otherwise, process the parameter into a ViewPathSet.
# * <tt>paths</tt> - If a PathSet is provided, use that;
# otherwise, process the parameter into a PathSet.
def view_paths=(paths)
self._view_paths = ActionView::Base.process_view_paths(paths)
self._view_paths.freeze
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/locking/optimistic.rb
Expand Up @@ -23,7 +23,7 @@ module Locking
# p2.first_name = "should fail"
# p2.save # Raises a ActiveRecord::StaleObjectError
#
# Optimistic locking will also check for stale data when objects are destroyed. Example:
# Optimistic locking will also check for stale data when objects are destroyed. Example:
#
# p1 = Person.find(1)
# p2 = Person.find(1)
Expand Down
6 changes: 3 additions & 3 deletions activerecord/lib/active_record/locking/pessimistic.rb
Expand Up @@ -9,9 +9,8 @@ module Locking
# Account.find(1, :lock => true)
#
# Pass <tt>:lock => 'some locking clause'</tt> to give a database-specific locking clause
# of your own such as 'LOCK IN SHARE MODE' or 'FOR UPDATE NOWAIT'.
# of your own such as 'LOCK IN SHARE MODE' or 'FOR UPDATE NOWAIT'. Example:
#
# Example:
# Account.transaction do
# # select * from accounts where name = 'shugo' limit 1 for update
# shugo = Account.where("name = 'shugo'").lock(true).first
Expand All @@ -24,6 +23,7 @@ module Locking
#
# You can also use ActiveRecord::Base#lock! method to lock one record by id.
# This may be better if you don't need to lock every row. Example:
#
# Account.transaction do
# # select * from accounts where ...
# accounts = Account.where(...).all
Expand All @@ -44,7 +44,7 @@ module Locking
module Pessimistic
# Obtain a row lock on this record. Reloads the record to obtain the requested
# lock. Pass an SQL locking clause to append the end of the SELECT statement
# or pass true for "FOR UPDATE" (the default, an exclusive row lock). Returns
# or pass true for "FOR UPDATE" (the default, an exclusive row lock). Returns
# the locked record.
def lock!(lock = true)
reload(:lock => lock) if persisted?
Expand Down
15 changes: 11 additions & 4 deletions activerecord/lib/active_record/validations/uniqueness.rb
Expand Up @@ -173,10 +173,17 @@ module ClassMethods
# This technique is also known as optimistic concurrency control:
# http://en.wikipedia.org/wiki/Optimistic_concurrency_control
#
# Active Record currently provides no way to distinguish unique
# index constraint errors from other types of database errors, so you
# will have to parse the (database-specific) exception message to detect
# such a case.
# The bundled ActiveRecord::ConnectionAdapters distinguish unique index
# constraint errors from other types of database errors by throwing an
# ActiveRecord::RecordNotUnique exception.
# For other adapters you will have to parse the (database-specific) exception
# message to detect such a case.
# The following bundled adapters throw the ActiveRecord::RecordNotUnique exception:
# * ActiveRecord::ConnectionAdapters::MysqlAdapter
# * ActiveRecord::ConnectionAdapters::Mysql2Adapter
# * ActiveRecord::ConnectionAdapters::SQLiteAdapter
# * ActiveRecord::ConnectionAdapters::SQLite3Adapter
# * ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
#
def validates_uniqueness_of(*attr_names)
validates_with UniquenessValidator, _merge_attributes(attr_names)
Expand Down
4 changes: 2 additions & 2 deletions railties/guides/source/3_0_release_notes.textile
Expand Up @@ -59,12 +59,12 @@ The +config.gem+ method is gone and has been replaced by using +bundler+ and a +

h4. Upgrade Process

To help with the upgrade process, a plugin named "Rails Upgrade":http://github.com/rails/rails_upgrade has been created to automate part of it.
To help with the upgrade process, a plugin named "Rails Upgrade":http://github.com/jm/rails_upgrade has been created to automate part of it.

Simply install the plugin, then run +rake rails:upgrade:check+ to check your app for pieces that need to be updated (with links to information on how to update them). It also offers a task to generate a +Gemfile+ based on your current +config.gem+ calls and a task to generate a new routes file from your current one. To get the plugin, simply run the following:

<shell>
$ ruby script/plugin install git://github.com/rails/rails_upgrade.git
$ ruby script/plugin install git://github.com/jm/rails_upgrade.git
</shell>

You can see an example of how that works at "Rails Upgrade is now an Official Plugin":http://omgbloglol.com/post/364624593/rails-upgrade-is-now-an-official-plugin
Expand Down
Expand Up @@ -461,11 +461,11 @@ The block receives the model, the attribute's name and the attribute's value. Yo

h3. Common Validation Options

There are some common options that all the validation helpers can use. Here they are, except for the +:if+ and +:unless+ options, which are discussed later in "Conditional Validation":#conditional-validation.
These are common validation options:

h4. +:allow_nil+

The +:allow_nil+ option skips the validation when the value being validated is +nil+. Using +:allow_nil+ with +validates_presence_of+ allows for +nil+, but any other +blank?+ value will still be rejected.
The +:allow_nil+ option skips the validation when the value being validated is +nil+.

<ruby>
class Coffee < ActiveRecord::Base
Expand All @@ -474,6 +474,8 @@ class Coffee < ActiveRecord::Base
end
</ruby>

TIP: +:allow_nil+ is ignored by the presence validator.

h4. +:allow_blank+

The +:allow_blank+ option is similar to the +:allow_nil+ option. This option will let validation pass if the attribute's value is +blank?+, like +nil+ or an empty string for example.
Expand All @@ -487,6 +489,8 @@ Topic.create("title" => "").valid? # => true
Topic.create("title" => nil).valid? # => true
</ruby>

TIP: +:allow_blank+ is ignored by the presence validator.

h4. +:message+

As you've already seen, the +:message+ option lets you specify the message that will be added to the +errors+ collection when validation fails. When this option is not used, Active Record will use the respective default error message for each validation helper.
Expand Down Expand Up @@ -742,7 +746,7 @@ Rails maintains an official plugin that provides helpers to display the error me

h4. Installing as a plugin
<shell>
$ rails plugin install git://github.com/rails/dynamic_form.git
$ rails plugin install git://github.com/joelmoss/dynamic_form.git
</shell>

h4 Installing as a Gem
Expand Down
13 changes: 0 additions & 13 deletions railties/guides/source/contributing_to_ruby_on_rails.textile
Expand Up @@ -364,19 +364,6 @@ Please make sure the patch does not introduce whitespace errors:
$ git apply --whitespace=error-all mynew_patch.diff
</shell>

You can check your patches by applying your patch to an different dedicated branch:

<shell>
$ git checkout -b testing_branch
$ git apply --check my_new_patch.diff
</shell>

You can make sure your patches don't add any whitespace by applying it yourself using the --whitespace=error-all option. Make sure you are on your dedicated test branche and:

<shell>
$ git apply --whitespace=error-all mynew_patch.diff
</shell>


h4. Create a Lighthouse Ticket

Expand Down
Expand Up @@ -686,7 +686,7 @@ There are some Rails plugins to help you to find errors and debug your applicati
* "Query Trace":https://github.com/ntalbott/query_trace/tree/master: Adds query origin tracing to your logs.
* "Query Stats":https://github.com/dan-manges/query_stats/tree/master: A Rails plugin to track database queries.
* "Query Reviewer":http://code.google.com/p/query-reviewer/: This rails plugin not only runs "EXPLAIN" before each of your select queries in development, but provides a small DIV in the rendered output of each page with the summary of warnings for each query that it analyzed.
* "Exception Notifier":https://github.com/rails/exception_notification/tree/master: Provides a mailer object and a default set of templates for sending email notifications when errors occur in a Rails application.
* "Exception Notifier":https://github.com/smartinez87/exception_notification/tree/master: Provides a mailer object and a default set of templates for sending email notifications when errors occur in a Rails application.
* "Exception Logger":https://github.com/defunkt/exception_logger/tree/master: Logs your Rails exceptions in the database and provides a funky web interface to manage them.

h3. References
Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/form_helpers.textile
Expand Up @@ -475,7 +475,7 @@ To leverage time zone support in Rails, you have to ask your users what time zon

There is also +time_zone_options_for_select+ helper for a more manual (therefore more customizable) way of doing this. Read the API documentation to learn about the possible arguments for these two methods.

Rails _used_ to have a +country_select+ helper for choosing countries, but this has been extracted to the "country_select plugin":https://github.com/rails/country_select/tree/master. When using this, be aware that the exclusion or inclusion of certain names from the list can be somewhat controversial (and was the reason this functionality was extracted from Rails).
Rails _used_ to have a +country_select+ helper for choosing countries, but this has been extracted to the "country_select plugin":https://github.com/chrislerum/country_select. When using this, be aware that the exclusion or inclusion of certain names from the list can be somewhat controversial (and was the reason this functionality was extracted from Rails).

h3. Using Date and Time Form Helpers

Expand Down
13 changes: 7 additions & 6 deletions railties/guides/source/plugins.textile
Expand Up @@ -45,9 +45,9 @@ as a gem. This tutorial will begin to bridge that gap by demonstrating how to c
"Enginex gem":http://www.github.com/josevalim/enginex.

<shell>
gem install enginex
enginex --help
enginex yaffle
$ gem install enginex
$ enginex --help
$ enginex yaffle
</shell>

This command will create a new directory named "yaffle" within the current directory.
Expand Down Expand Up @@ -401,7 +401,9 @@ h3. Publishing your Gem
Gem plugins in progress can be easily be shared from any Git repository. To share the Yaffle gem with others, simply
commit the code to a Git repository (like Github) and add a line to the Gemfile of the any application:

gem 'yaffle', :git => 'git://github.com/yaffle_watcher/yaffle.git'
<ruby>
gem 'yaffle', :git => 'git://github.com/yaffle_watcher/yaffle.git'
</ruby>

After running +bundle install+, your gem functionality will be available to the application.

Expand Down Expand Up @@ -450,8 +452,6 @@ Once your comments are good to go, navigate to your plugin directory and run:
$ rake rdoc
</shell>

!!!!!!!!!!!!!! Make sure these still make sense. Add any references that you see fit. !!!!!!!!!!!!!

h4. References

* "Developing a RubyGem using Bundler":https://github.com/radar/guides/blob/master/gem-development.md
Expand All @@ -462,6 +462,7 @@ h4. References

h3. Changelog

* March 10, 2011: Minor formatting tweaks.
* February 13, 2011: Get guide in synch with Rails 3.0.3. Remove information not compatible with Rails 3. Send reader elsewhere
for information that is covered elsewhere.
* April 4, 2010: Fixed document to validate XHTML 1.0 Strict. "Jaime Iniesta":http://jaimeiniesta.com
Expand Down
2 changes: 2 additions & 0 deletions railties/guides/source/testing.textile
Expand Up @@ -500,6 +500,8 @@ If you're familiar with the HTTP protocol, you'll know that +get+ is a type of r

All of request types are methods that you can use, however, you'll probably end up using the first two more often than the others.

NOTE: Functional tests do not verify whether the specified request type should be accepted by the action. Request types in this context exist to make your tests more descriptive.

h4. The Four Hashes of the Apocalypse

After a request has been made by using one of the 5 methods (+get+, +post+, etc.) and processed, you will have 4 Hash objects ready for use:
Expand Down

0 comments on commit 21b12d8

Please sign in to comment.