Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lifo/docrails
Browse files Browse the repository at this point in the history
Conflicts:
	activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
	activerecord/test/cases/adapter_test.rb
	guides/source/testing.md

[ci skip]
  • Loading branch information
vijaydev committed Mar 30, 2013
2 parents 022ed6c + 6bd1bbe commit 6d8c070
Show file tree
Hide file tree
Showing 44 changed files with 274 additions and 208 deletions.
4 changes: 2 additions & 2 deletions actionmailer/README.rdoc
@@ -1,6 +1,6 @@
= Action Mailer -- Easy email delivery and testing

Action Mailer is a framework for designing email-service layers. These layers
Action Mailer is a framework for designing email service layers. These layers
are used to consolidate code for sending out forgotten passwords, welcome
wishes on signup, invoices for billing, and any other use case that requires
a written notification to either a person or another system.
Expand Down Expand Up @@ -78,7 +78,7 @@ Or you can just chain the methods together like:

It is possible to set default values that will be used in every method in your Action Mailer class. To implement this functionality, you just call the public class method <tt>default</tt> which you get for free from ActionMailer::Base. This method accepts a Hash as the parameter. You can use any of the headers e-mail messages has, like <tt>:from</tt> as the key. You can also pass in a string as the key, like "Content-Type", but Action Mailer does this out of the box for you, so you won't need to worry about that. Finally, it is also possible to pass in a Proc that will get evaluated when it is needed.

Note that every value you set with this method will get over written if you use the same key in your mailer method.
Note that every value you set with this method will get overwritten if you use the same key in your mailer method.

Example:

Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/abstract_controller/base.rb
Expand Up @@ -35,7 +35,7 @@ def abstract!
end

def inherited(klass) # :nodoc:
# define the abstract ivar on subclasses so that we don't get
# Define the abstract ivar on subclasses so that we don't get
# uninitialized ivar warnings
unless klass.instance_variable_defined?(:@abstract)
klass.instance_variable_set(:@abstract, false)
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/abstract_controller/helpers.rb
Expand Up @@ -59,7 +59,7 @@ def #{meth}(*args, &blk) # def current_user(*args,
# The +helper+ class method can take a series of helper module names, a block, or both.
#
# ==== Options
# * <tt>*args</tt> - Module, Symbol, String, :all
# * <tt>*args</tt> - Module, Symbol, String
# * <tt>block</tt> - A block defining helper methods
#
# When the argument is a module it will be included directly in the template class.
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/http/upload.rb
Expand Up @@ -6,7 +6,7 @@ module Http
# of its interface is available directly for convenience.
#
# Uploaded files are temporary files whose lifespan is one request. When
# the object is finalized Ruby unlinks the file, so there is not need to
# the object is finalized Ruby unlinks the file, so there is no need to
# clean them with a separate maintenance task.
class UploadedFile
# The basename of the file in the client.
Expand Down
92 changes: 28 additions & 64 deletions actionpack/lib/action_dispatch/routing.rb
Expand Up @@ -69,6 +69,22 @@ module ActionDispatch
# <tt>Routing::Mapper::Scoping#namespace</tt>, and
# <tt>Routing::Mapper::Scoping#scope</tt>.
#
# == Non-resourceful routes
#
# For routes that don't fit the <tt>resources</tt> mold, you can use the HTTP helper
# methods <tt>get</tt>, <tt>post</tt>, <tt>patch</tt>, <tt>put</tt> and <tt>delete</tt>.
#
# get 'post/:id' => 'posts#show'
# post 'post/:id' => 'posts#create_comment'
#
# If your route needs to respond to more than one HTTP method (or all methods) then using the
# <tt>:via</tt> option on <tt>match</tt> is preferable.
#
# match 'post/:id' => 'posts#show', via: [:get, :post]
#
# Now, if you POST to <tt>/posts/:id</tt>, it will route to the <tt>create_comment</tt> action. A GET on the same
# URL will route to the <tt>show</tt> action.
#
# == Named routes
#
# Routes can be named by passing an <tt>:as</tt> option,
Expand All @@ -78,7 +94,7 @@ module ActionDispatch
# Example:
#
# # In routes.rb
# match '/login' => 'accounts#login', as: 'login'
# get '/login' => 'accounts#login', as: 'login'
#
# # With render, redirect_to, tests, etc.
# redirect_to login_url
Expand All @@ -104,9 +120,9 @@ module ActionDispatch
#
# # In routes.rb
# controller :blog do
# match 'blog/show' => :list
# match 'blog/delete' => :delete
# match 'blog/edit/:id' => :edit
# get 'blog/show' => :list
# get 'blog/delete' => :delete
# get 'blog/edit/:id' => :edit
# end
#
# # provides named routes for show, delete, and edit
Expand All @@ -116,7 +132,7 @@ module ActionDispatch
#
# Routes can generate pretty URLs. For example:
#
# match '/articles/:year/:month/:day' => 'articles#find_by_id', constraints: {
# get '/articles/:year/:month/:day' => 'articles#find_by_id', constraints: {
# year: /\d{4}/,
# month: /\d{1,2}/,
# day: /\d{1,2}/
Expand All @@ -131,103 +147,51 @@ module ActionDispatch
# You can specify a regular expression to define a format for a parameter.
#
# controller 'geocode' do
# match 'geocode/:postalcode' => :show, constraints: {
# get 'geocode/:postalcode' => :show, constraints: {
# postalcode: /\d{5}(-\d{4})?/
# }
#
# Constraints can include the 'ignorecase' and 'extended syntax' regular
# expression modifiers:
#
# controller 'geocode' do
# match 'geocode/:postalcode' => :show, constraints: {
# get 'geocode/:postalcode' => :show, constraints: {
# postalcode: /hx\d\d\s\d[a-z]{2}/i
# }
# end
#
# controller 'geocode' do
# match 'geocode/:postalcode' => :show, constraints: {
# get 'geocode/:postalcode' => :show, constraints: {
# postalcode: /# Postcode format
# \d{5} #Prefix
# (-\d{4})? #Suffix
# /x
# }
# end
#
# Using the multiline match modifier will raise an +ArgumentError+.
# Using the multiline modifier will raise an +ArgumentError+.
# Encoding regular expression modifiers are silently ignored. The
# match will always use the default encoding or ASCII.
#
# == Default route
#
# Consider the following route, which you will find commented out at the
# bottom of your generated <tt>config/routes.rb</tt>:
#
# match ':controller(/:action(/:id))(.:format)'
#
# This route states that it expects requests to consist of a
# <tt>:controller</tt> followed optionally by an <tt>:action</tt> that in
# turn is followed optionally by an <tt>:id</tt>, which in turn is followed
# optionally by a <tt>:format</tt>.
#
# Suppose you get an incoming request for <tt>/blog/edit/22</tt>, you'll end
# up with:
#
# params = { controller: 'blog',
# action: 'edit',
# id: '22'
# }
#
# By not relying on default routes, you improve the security of your
# application since not all controller actions, which includes actions you
# might add at a later time, are exposed by default.
#
# == HTTP Methods
#
# Using the <tt>:via</tt> option when specifying a route allows you to
# restrict it to a specific HTTP method. Possible values are <tt>:post</tt>,
# <tt>:get</tt>, <tt>:patch</tt>, <tt>:put</tt>, <tt>:delete</tt> and
# <tt>:any</tt>. If your route needs to respond to more than one method you
# can use an array, e.g. <tt>[ :get, :post ]</tt>. The default value is
# <tt>:any</tt> which means that the route will respond to any of the HTTP
# methods.
#
# match 'post/:id' => 'posts#show', via: :get
# match 'post/:id' => 'posts#create_comment', via: :post
#
# Now, if you POST to <tt>/posts/:id</tt>, it will route to the <tt>create_comment</tt> action. A GET on the same
# URL will route to the <tt>show</tt> action.
#
# === HTTP helper methods
#
# An alternative method of specifying which HTTP method a route should respond to is to use the helper
# methods <tt>get</tt>, <tt>post</tt>, <tt>patch</tt>, <tt>put</tt> and <tt>delete</tt>.
#
# get 'post/:id' => 'posts#show'
# post 'post/:id' => 'posts#create_comment'
#
# This syntax is less verbose and the intention is more apparent to someone else reading your code,
# however if your route needs to respond to more than one HTTP method (or all methods) then using the
# <tt>:via</tt> option on <tt>match</tt> is preferable.
#
# == External redirects
#
# You can redirect any path to another path using the redirect helper in your router:
#
# match "/stories" => redirect("/posts")
# get "/stories" => redirect("/posts")
#
# == Unicode character routes
#
# You can specify unicode character routes in your router:
#
# match "こんにちは" => "welcome#index"
# get "こんにちは" => "welcome#index"
#
# == Routing to Rack Applications
#
# Instead of a String, like <tt>posts#index</tt>, which corresponds to the
# index action in the PostsController, you can specify any Rack application
# as the endpoint for a matcher:
#
# match "/application.js" => Sprockets
# get "/application.js" => Sprockets
#
# == Reloading routes
#
Expand Down
16 changes: 0 additions & 16 deletions actionpack/lib/action_view/helpers/form_helper.rb
Expand Up @@ -655,14 +655,6 @@ def apply_form_for_options!(record, object, options) #:nodoc:
# ...
# <% end %>
#
# When projects is already an association on Person you can use
# +accepts_nested_attributes_for+ to define the writer method for you:
#
# class Person < ActiveRecord::Base
# has_many :projects
# accepts_nested_attributes_for :projects
# end
#
# If you want to destroy any of the associated models through the
# form, you have to enable it first using the <tt>:allow_destroy</tt>
# option for +accepts_nested_attributes_for+:
Expand Down Expand Up @@ -1425,14 +1417,6 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
# ...
# <% end %>
#
# When projects is already an association on Person you can use
# +accepts_nested_attributes_for+ to define the writer method for you:
#
# class Person < ActiveRecord::Base
# has_many :projects
# accepts_nested_attributes_for :projects
# end
#
# If you want to destroy any of the associated models through the
# form, you have to enable it first using the <tt>:allow_destroy</tt>
# option for +accepts_nested_attributes_for+:
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/template/resolver.rb
Expand Up @@ -255,7 +255,7 @@ def extract_handler_and_format(path, default_formats)
#
# FileSystemResolver.new("/path/to/views", ":prefix/:action{.:locale,}{.:formats,}{.:handlers,}")
#
# This one allows you to keep files with different formats in seperated subdirectories,
# This one allows you to keep files with different formats in separate subdirectories,
# eg. `users/new.html` will be loaded from `users/html/new.erb` or `users/new.html.erb`,
# `users/new.js` from `users/js/new.erb` or `users/new.js.erb`, etc.
#
Expand Down
2 changes: 1 addition & 1 deletion activemodel/README.rdoc
Expand Up @@ -2,7 +2,7 @@

Active Model provides a known set of interfaces for usage in model classes.
They allow for Action Pack helpers to interact with non-Active Record models,
for example. Active Model also helps building custom ORMs for use outside of
for example. Active Model also helps with building custom ORMs for use outside of
the Rails framework.

Prior to Rails 3.0, if a plugin or gem developer wanted to have an object
Expand Down
4 changes: 2 additions & 2 deletions activerecord/README.rdoc
Expand Up @@ -190,7 +190,7 @@ The latest version of Active Record can be installed with RubyGems:

% [sudo] gem install activerecord

Source code can be downloaded as part of the Rails project on GitHub
Source code can be downloaded as part of the Rails project on GitHub:

* https://github.com/rails/rails/tree/master/activerecord

Expand All @@ -204,7 +204,7 @@ Active Record is released under the MIT license:

== Support

API documentation is at
API documentation is at:

* http://api.rubyonrails.org

Expand Down
8 changes: 4 additions & 4 deletions activerecord/lib/active_record/associations.rb
Expand Up @@ -1115,11 +1115,11 @@ module ClassMethods
# similar callbacks may affect the :dependent behavior, and the
# :dependent behavior may affect other callbacks.
#
# * <tt>:destroy</tt> causes all the associated objects to also be destroyed
# * <tt>:delete_all</tt> causes all the associated objects to be deleted directly from the database (so callbacks will not execute)
# * <tt>:destroy</tt> causes all the associated objects to also be destroyed.
# * <tt>:delete_all</tt> causes all the associated objects to be deleted directly from the database (so callbacks will not be executed).
# * <tt>:nullify</tt> causes the foreign keys to be set to +NULL+. Callbacks are not executed.
# * <tt>:restrict_with_exception</tt> causes an exception to be raised if there are any associated records
# * <tt>:restrict_with_error</tt> causes an error to be added to the owner if there are any associated objects
# * <tt>:restrict_with_exception</tt> causes an exception to be raised if there are any associated records.
# * <tt>:restrict_with_error</tt> causes an error to be added to the owner if there are any associated objects.
#
# If using with the <tt>:through</tt> option, the association on the join model must be
# a +belongs_to+, and the records which get deleted are the join records, rather than
Expand Down
3 changes: 2 additions & 1 deletion activerecord/lib/active_record/associations/association.rb
Expand Up @@ -217,7 +217,8 @@ def inverse_reflection_for(record)
reflection.inverse_of
end

# Is this association invertible? Can be redefined by subclasses.
# Returns true if inverse association on the given record needs to be set.
# This method is redefined by subclasses.
def invertible_for?(record)
inverse_reflection_for(record)
end
Expand Down
Expand Up @@ -4,7 +4,7 @@
require 'mysql2'

module ActiveRecord
module ConnectionHandling
module ConnectionHandling # :nodoc:
# Establishes a connection to the database that's used by all Active Record objects.
def mysql2_connection(config)
config = config.symbolize_keys
Expand Down
Expand Up @@ -16,9 +16,9 @@ class Result; include Enumerable end
end

module ActiveRecord
module ConnectionHandling
module ConnectionHandling # :nodoc:
# Establishes a connection to the database that's used by all Active Record objects.
def mysql_connection(config) # :nodoc:
def mysql_connection(config)
config = config.symbolize_keys
host = config[:host]
port = config[:port]
Expand Down
Expand Up @@ -16,15 +16,15 @@
require 'ipaddr'

module ActiveRecord
module ConnectionHandling
module ConnectionHandling # :nodoc:
VALID_CONN_PARAMS = [:host, :hostaddr, :port, :dbname, :user, :password, :connect_timeout,
:client_encoding, :options, :application_name, :fallback_application_name,
:keepalives, :keepalives_idle, :keepalives_interval, :keepalives_count,
:tty, :sslmode, :requiressl, :sslcert, :sslkey, :sslrootcert, :sslcrl,
:requirepeer, :krbsrvname, :gsslib, :service]

# Establishes a connection to the database that's used by all Active Record objects
def postgresql_connection(config) # :nodoc:
def postgresql_connection(config)
conn_params = config.symbolize_keys

conn_params.delete_if { |_, v| v.nil? }
Expand Down
Expand Up @@ -6,9 +6,9 @@
require 'sqlite3'

module ActiveRecord
module ConnectionHandling
module ConnectionHandling # :nodoc:
# sqlite3 adapter reuses sqlite_connection.
def sqlite3_connection(config) # :nodoc:
def sqlite3_connection(config)
# Require database.
unless config[:database]
raise ArgumentError, "No database file specified. Missing argument: database"
Expand Down
10 changes: 5 additions & 5 deletions activerecord/lib/active_record/connection_handling.rb
Expand Up @@ -15,15 +15,15 @@ module ConnectionHandling
# Example for SQLite database:
#
# ActiveRecord::Base.establish_connection(
# adapter: "sqlite",
# database: "path/to/dbfile"
# adapter: "sqlite",
# database: "path/to/dbfile"
# )
#
# Also accepts keys as strings (for parsing from YAML for example):
#
# ActiveRecord::Base.establish_connection(
# "adapter" => "sqlite",
# "database" => "path/to/dbfile"
# "adapter" => "sqlite",
# "database" => "path/to/dbfile"
# )
#
# Or a URL:
Expand Down Expand Up @@ -79,7 +79,7 @@ def retrieve_connection
connection_handler.retrieve_connection(self)
end

# Returns true if Active Record is connected.
# Returns +true+ if Active Record is connected.
def connected?
connection_handler.connected?(self)
end
Expand Down

0 comments on commit 6d8c070

Please sign in to comment.