mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge branch 'master' of github.com:lifo/docrails
Conflicts: railties/guides/source/active_record_querying.textile
This commit is contained in:
@@ -213,7 +213,7 @@ module AbstractController
|
||||
# true:: raise an ArgumentError
|
||||
#
|
||||
# ==== Parameters
|
||||
# * <tt>String, Symbol, false</tt> - The layout to use.
|
||||
# * <tt>layout</tt> - The layout to use.
|
||||
#
|
||||
# ==== Options (conditions)
|
||||
# * :only - A list of actions to apply this layout to.
|
||||
@@ -310,14 +310,10 @@ module AbstractController
|
||||
# This will be overwritten by _write_layout_method
|
||||
def _layout; end
|
||||
|
||||
# Determine the layout for a given name and details, taking into account
|
||||
# the name type.
|
||||
# Determine the layout for a given name, taking into account the name type.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * <tt>name</tt> - The name of the template
|
||||
# * <tt>details</tt> - A list of details to restrict
|
||||
# the lookup to. By default, layout lookup is limited to the
|
||||
# formats specified for the current request.
|
||||
def _layout_for_option(name)
|
||||
case name
|
||||
when String then name
|
||||
@@ -330,15 +326,12 @@ module AbstractController
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the default layout for this controller and a given set of details.
|
||||
# Returns the default layout for this controller.
|
||||
# Optionally raises an exception if the layout could not be found.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * <tt>details</tt> - A list of details to restrict the search by. This
|
||||
# might include details like the format or locale of the template.
|
||||
# * <tt>require_layout</tt> - If this is true, raise an ArgumentError
|
||||
# with details about the fact that the exception could not be
|
||||
# found (defaults to false)
|
||||
# * <tt>require_layout</tt> - If set to true and layout is not found,
|
||||
# an ArgumentError exception is raised (defaults to false)
|
||||
#
|
||||
# ==== Returns
|
||||
# * <tt>template</tt> - The template object for the default layout (or nil)
|
||||
|
||||
@@ -94,7 +94,7 @@ module ActionView
|
||||
# If +html_options+ has an <tt>:onclick</tt>, that one is put before +function+. Once all
|
||||
# the JavaScript is set, the helper appends "; return false;".
|
||||
#
|
||||
# The +href+ attribute of the tag is set to "#" unles +html_options+ has one.
|
||||
# The +href+ attribute of the tag is set to "#" unless +html_options+ has one.
|
||||
#
|
||||
# link_to_function "Greeting", "alert('Hello world!')", :class => "nav_link"
|
||||
# # => <a class="nav_link" href="#" onclick="alert('Hello world!'); return false;">Greeting</a>
|
||||
|
||||
@@ -150,7 +150,7 @@ A short rundown of some of the major features:
|
||||
* Database agnostic schema management with Migrations.
|
||||
|
||||
class AddSystemSettings < ActiveRecord::Migration
|
||||
def self.up
|
||||
def up
|
||||
create_table :system_settings do |t|
|
||||
t.string :name
|
||||
t.string :label
|
||||
@@ -162,7 +162,7 @@ A short rundown of some of the major features:
|
||||
SystemSetting.create :name => "notice", :label => "Use notice?", :value => 1
|
||||
end
|
||||
|
||||
def self.down
|
||||
def down
|
||||
drop_table :system_settings
|
||||
end
|
||||
end
|
||||
|
||||
@@ -760,7 +760,7 @@ module ActiveRecord #:nodoc:
|
||||
# values, eg:
|
||||
#
|
||||
# class CreateJobLevels < ActiveRecord::Migration
|
||||
# def self.up
|
||||
# def up
|
||||
# create_table :job_levels do |t|
|
||||
# t.integer :id
|
||||
# t.string :name
|
||||
@@ -774,7 +774,7 @@ module ActiveRecord #:nodoc:
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def self.down
|
||||
# def down
|
||||
# drop_table :job_levels
|
||||
# end
|
||||
# end
|
||||
|
||||
@@ -46,13 +46,13 @@ module ActiveRecord
|
||||
# +change_table+ is actually of this type:
|
||||
#
|
||||
# class SomeMigration < ActiveRecord::Migration
|
||||
# def self.up
|
||||
# def up
|
||||
# create_table :foo do |t|
|
||||
# puts t.class # => "ActiveRecord::ConnectionAdapters::TableDefinition"
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def self.down
|
||||
# def down
|
||||
# ...
|
||||
# end
|
||||
# end
|
||||
@@ -479,4 +479,3 @@ module ActiveRecord
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -112,8 +112,8 @@ module ActiveRecord
|
||||
# a column but keeps the type and content.
|
||||
# * <tt>change_column(table_name, column_name, type, options)</tt>: Changes
|
||||
# the column to a different type using the same parameters as add_column.
|
||||
# * <tt>remove_column(table_name, column_name)</tt>: Removes the column named
|
||||
# +column_name+ from the table called +table_name+.
|
||||
# * <tt>remove_column(table_name, column_names)</tt>: Removes the column listed in
|
||||
# +column_names+ from the table called +table_name+.
|
||||
# * <tt>add_index(table_name, column_names, options)</tt>: Adds a new index
|
||||
# with the name of the column. Other options include
|
||||
# <tt>:name</tt>, <tt>:unique</tt> (e.g.
|
||||
|
||||
@@ -1287,19 +1287,19 @@ User.where(:id => 1).joins(:posts).explain
|
||||
may yield
|
||||
|
||||
<plain>
|
||||
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+
|
||||
<plus>----<plus>-------------<plus>-------<plus>-------<plus>---------------<plus>---------<plus>---------<plus>-------<plus>------<plus>-------------<plus>
|
||||
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
||||
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+
|
||||
<plus>----<plus>-------------<plus>-------<plus>-------<plus>---------------<plus>---------<plus>---------<plus>-------<plus>------<plus>-------------<plus>
|
||||
| 1 | SIMPLE | users | const | PRIMARY | PRIMARY | 4 | const | 1 | |
|
||||
| 1 | SIMPLE | posts | ALL | NULL | NULL | NULL | NULL | 1 | Using where |
|
||||
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+
|
||||
<plus>----<plus>-------------<plus>-------<plus>-------<plus>---------------<plus>---------<plus>---------<plus>-------<plus>------<plus>-------------<plus>
|
||||
2 rows in set (0.00 sec)
|
||||
</plain>
|
||||
|
||||
under MySQL.
|
||||
|
||||
Active Record performs a pretty printing that emulates the one of the database
|
||||
shells. So, the same query running with the PostreSQL adapter would yield instead
|
||||
shells. So, the same query running with the PostgreSQL adapter would yield instead
|
||||
|
||||
<plain>
|
||||
QUERY PLAN
|
||||
@@ -1324,17 +1324,17 @@ User.where(:id => 1).includes(:posts).explain
|
||||
yields
|
||||
|
||||
<plain>
|
||||
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
|
||||
<plus>----<plus>-------------<plus>-------<plus>-------<plus>---------------<plus>---------<plus>---------<plus>-------<plus>------<plus>-------<plus>
|
||||
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
||||
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
|
||||
<plus>----<plus>-------------<plus>-------<plus>-------<plus>---------------<plus>---------<plus>---------<plus>-------<plus>------<plus>-------<plus>
|
||||
| 1 | SIMPLE | users | const | PRIMARY | PRIMARY | 4 | const | 1 | |
|
||||
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
|
||||
<plus>----<plus>-------------<plus>-------<plus>-------<plus>---------------<plus>---------<plus>---------<plus>-------<plus>------<plus>-------<plus>
|
||||
1 row in set (0.00 sec)
|
||||
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
|
||||
<plus>----<plus>-------------<plus>-------<plus>------<plus>---------------<plus>------<plus>---------<plus>------<plus>------<plus>-------------<plus>
|
||||
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
||||
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
|
||||
<plus>----<plus>-------------<plus>-------<plus>------<plus>---------------<plus>------<plus>---------<plus>------<plus>------<plus>-------------<plus>
|
||||
| 1 | SIMPLE | posts | ALL | NULL | NULL | NULL | NULL | 1 | Using where |
|
||||
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
|
||||
<plus>----<plus>-------------<plus>-------<plus>------<plus>---------------<plus>------<plus>---------<plus>------<plus>------<plus>-------------<plus>
|
||||
1 row in set (0.00 sec)
|
||||
</plain>
|
||||
|
||||
|
||||
@@ -1234,7 +1234,7 @@ If you need to evaluate conditions dynamically at runtime, use a proc:
|
||||
<ruby>
|
||||
class Customer < ActiveRecord::Base
|
||||
has_many :latest_orders, :class_name => "Order",
|
||||
:conditions => proc { "orders.created_at > #{10.hours.ago.to_s(:db).inspect}" }
|
||||
:conditions => proc { ["orders.created_at > ?, 10.hours.ago] }
|
||||
end
|
||||
</ruby>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user