Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
4b9dba99
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4b9dba99
编写于
1月 03, 2015
作者:
V
Vijay Dev
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of github.com:rails/docrails
上级
02e72a49
7cc145ec
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
74 addition
and
40 deletion
+74
-40
actionpack/lib/abstract_controller/base.rb
actionpack/lib/abstract_controller/base.rb
+12
-8
actionpack/lib/abstract_controller/callbacks.rb
actionpack/lib/abstract_controller/callbacks.rb
+5
-4
actionpack/lib/abstract_controller/rendering.rb
actionpack/lib/abstract_controller/rendering.rb
+7
-6
actionview/lib/action_view/renderer/partial_renderer.rb
actionview/lib/action_view/renderer/partial_renderer.rb
+5
-5
activemodel/lib/active_model/conversion.rb
activemodel/lib/active_model/conversion.rb
+3
-3
activemodel/lib/active_model/dirty.rb
activemodel/lib/active_model/dirty.rb
+1
-1
activemodel/lib/active_model/gem_version.rb
activemodel/lib/active_model/gem_version.rb
+1
-1
activemodel/lib/active_model/naming.rb
activemodel/lib/active_model/naming.rb
+1
-1
activemodel/lib/active_model/serializers/xml.rb
activemodel/lib/active_model/serializers/xml.rb
+1
-1
activemodel/lib/active_model/validations/absence.rb
activemodel/lib/active_model/validations/absence.rb
+1
-1
activemodel/lib/active_model/validator.rb
activemodel/lib/active_model/validator.rb
+1
-1
activemodel/lib/active_model/version.rb
activemodel/lib/active_model/version.rb
+1
-1
activerecord/lib/active_record/querying.rb
activerecord/lib/active_record/querying.rb
+4
-3
activesupport/lib/active_support/core_ext/name_error.rb
activesupport/lib/active_support/core_ext/name_error.rb
+14
-0
activesupport/lib/active_support/core_ext/object/try.rb
activesupport/lib/active_support/core_ext/object/try.rb
+9
-3
guides/source/active_job_basics.md
guides/source/active_job_basics.md
+0
-1
railties/lib/rails.rb
railties/lib/rails.rb
+8
-0
未找到文件。
actionpack/lib/abstract_controller/base.rb
浏览文件 @
4b9dba99
...
...
@@ -12,7 +12,7 @@ class Error < StandardError #:nodoc:
class
ActionNotFound
<
StandardError
end
#
<tt>AbstractController::Base</tt>
is a low-level API. Nobody should be
#
AbstractController::Base
is a low-level API. Nobody should be
# using it directly, and subclasses (like ActionController::Base) are
# expected to provide their own +render+ method, since rendering means
# different things depending on the context.
...
...
@@ -69,9 +69,9 @@ def hidden_actions
# A list of method names that should be considered actions. This
# includes all public instance methods on a controller, less
# any internal methods (see
#
internal_methods), adding back in
# any internal methods (see internal_methods), adding back in
# any methods that are internal, but still exist on the class
# itself. Finally,
#
hidden_actions are removed.
# itself. Finally, hidden_actions are removed.
#
# ==== Returns
# * <tt>Set</tt> - A set of all methods that should be considered actions.
...
...
@@ -92,15 +92,19 @@ def action_methods
end
# action_methods are cached and there is sometimes need to refresh
# them. clear_action_methods! allows you to do that, so next time
# them.
::
clear_action_methods! allows you to do that, so next time
# you run action_methods, they will be recalculated
def
clear_action_methods!
@action_methods
=
nil
end
# Returns the full controller name, underscored, without the ending Controller.
# For instance, MyApp::MyPostsController would return "my_app/my_posts" for
# controller_path.
#
# class MyApp
# MyPostsController < AbstractController::Base
# end
# end
# MyApp::MyPostsController.controller_path # => "my_app/my_posts"
#
# ==== Returns
# * <tt>String</tt>
...
...
@@ -137,12 +141,12 @@ def process(action, *args)
process_action
(
action_name
,
*
args
)
end
# Delegates to the class'
#
controller_path
# Delegates to the class'
::
controller_path
def
controller_path
self
.
class
.
controller_path
end
# Delegates to the class'
#
action_methods
# Delegates to the class'
::
action_methods
def
action_methods
self
.
class
.
action_methods
end
...
...
actionpack/lib/abstract_controller/callbacks.rb
浏览文件 @
4b9dba99
...
...
@@ -22,10 +22,11 @@ def process_action(*args)
end
module
ClassMethods
# If :only or :except are used, convert the options into the
# :unless and :if options of ActiveSupport::Callbacks.
# The basic idea is that :only => :index gets converted to
# :if => proc {|c| c.action_name == "index" }.
# If +:only+ or +:except+ are used, convert the options into the
# +:if+ and +:unless+ options of ActiveSupport::Callbacks.
#
# The basic idea is that <tt>:only => :index</tt> gets converted to
# <tt>:if => proc {|c| c.action_name == "index" }</tt>.
#
# ==== Options
# * <tt>only</tt> - The callback should be run only for this action
...
...
actionpack/lib/abstract_controller/rendering.rb
浏览文件 @
4b9dba99
...
...
@@ -18,7 +18,7 @@ module Rendering
include
ActionView
::
ViewPaths
# Normalize arguments, options and then delegates render_to_body and
# sticks the result in
self.response_body
.
# sticks the result in
<tt>self.response_body</tt>
.
# :api: public
def
render
(
*
args
,
&
block
)
options
=
_normalize_render
(
*
args
,
&
block
)
...
...
@@ -30,11 +30,11 @@ def render(*args, &block)
# Raw rendering of a template to a string.
#
# It is similar to render, except that it does not
# set the
response_body
and it should be guaranteed
# set the
+response_body+
and it should be guaranteed
# to always return a string.
#
# If a component extends the semantics of
response_body
# (as Action
Controller extends it to be anything that
# If a component extends the semantics of
+response_body+
# (as ActionController extends it to be anything that
# responds to the method each), this method needs to be
# overridden in order to still return a string.
# :api: plugin
...
...
@@ -73,8 +73,9 @@ def view_assigns
}
end
# Normalize args by converting render "foo" to render :action => "foo" and
# render "foo/bar" to render :file => "foo/bar".
# Normalize args by converting <tt>render "foo"</tt> to
# <tt>render :action => "foo"</tt> and <tt>render "foo/bar"</tt> to
# <tt>render :file => "foo/bar"</tt>.
# :api: plugin
def
_normalize_args
(
action
=
nil
,
options
=
{})
if
action
.
is_a?
Hash
...
...
actionview/lib/action_view/renderer/partial_renderer.rb
浏览文件 @
4b9dba99
...
...
@@ -73,7 +73,7 @@ def iterate! # :nodoc:
#
# <%= render partial: "account", locals: { user: @buyer } %>
#
# == Rendering a collection of partials
# ==
\
Rendering a collection of partials
#
# The example of partial use describes a familiar pattern where a template needs to iterate over an array and
# render a sub template for each of the elements. This pattern has been implemented as a single method that
...
...
@@ -105,7 +105,7 @@ def iterate! # :nodoc:
# NOTE: Due to backwards compatibility concerns, the collection can't be one of hashes. Normally you'd also
# just keep domain objects, like Active Records, in there.
#
# == Rendering shared partials
# ==
\
Rendering shared partials
#
# Two controllers can share a set of partials and render them like this:
#
...
...
@@ -113,7 +113,7 @@ def iterate! # :nodoc:
#
# This will render the partial "advertisement/_ad.html.erb" regardless of which controller this is being called from.
#
# == Rendering objects that respond to `to_partial_path`
# ==
\
Rendering objects that respond to `to_partial_path`
#
# Instead of explicitly naming the location of a partial, you can also let PartialRenderer do the work
# and pick the proper path by checking `to_partial_path` method.
...
...
@@ -127,7 +127,7 @@ def iterate! # :nodoc:
# # <%= render partial: "posts/post", collection: @posts %>
# <%= render partial: @posts %>
#
# == Rendering the default case
# ==
\
Rendering the default case
#
# If you're not going to be using any of the options like collections or layouts, you can also use the short-hand
# defaults of render to render partials. Examples:
...
...
@@ -147,7 +147,7 @@ def iterate! # :nodoc:
# # <%= render partial: "posts/post", collection: @posts %>
# <%= render @posts %>
#
# == Rendering partials with layouts
# ==
\
Rendering partials with layouts
#
# Partials can have their own layouts applied to them. These layouts are different than the ones that are
# specified globally for the entire action, but they work in a similar fashion. Imagine a list with two types
...
...
activemodel/lib/active_model/conversion.rb
浏览文件 @
4b9dba99
...
...
@@ -22,7 +22,7 @@ module ActiveModel
module
Conversion
extend
ActiveSupport
::
Concern
# If your object is already designed to implement all of the
Active
Model
# If your object is already designed to implement all of the
\Active \
Model
# you can use the default <tt>:to_model</tt> implementation, which simply
# returns +self+.
#
...
...
@@ -33,9 +33,9 @@ module Conversion
# person = Person.new
# person.to_model == person # => true
#
# If your model does not act like an
Active
Model object, then you should
# If your model does not act like an
\Active \
Model object, then you should
# define <tt>:to_model</tt> yourself returning a proxy object that wraps
# your object with
Active
Model compliant methods.
# your object with
\Active \
Model compliant methods.
def
to_model
self
end
...
...
activemodel/lib/active_model/dirty.rb
浏览文件 @
4b9dba99
...
...
@@ -102,7 +102,7 @@ module ActiveModel
#
# If an attribute is modified in-place then make use of
# +[attribute_name]_will_change!+ to mark that the attribute is changing.
# Otherwise
Active
Model can't track changes to in-place attributes. Note
# Otherwise
\Active \
Model can't track changes to in-place attributes. Note
# that Active Record can detect in-place modifications automatically. You do
# not need to call +[attribute_name]_will_change!+ on Active Record models.
#
...
...
activemodel/lib/active_model/gem_version.rb
浏览文件 @
4b9dba99
module
ActiveModel
# Returns the version of the currently loaded
Active
Model as a <tt>Gem::Version</tt>
# Returns the version of the currently loaded
\Active \
Model as a <tt>Gem::Version</tt>
def
self
.
gem_version
Gem
::
Version
.
new
VERSION
::
STRING
end
...
...
activemodel/lib/active_model/naming.rb
浏览文件 @
4b9dba99
...
...
@@ -211,7 +211,7 @@ def _singularize(string, replacement='_')
# BookModule::BookCover.model_name.i18n_key # => :"book_module/book_cover"
#
# Providing the functionality that ActiveModel::Naming provides in your object
# is required to pass the
Active
Model Lint test. So either extending the
# is required to pass the
\Active \
Model Lint test. So either extending the
# provided method below, or rolling your own is required.
module
Naming
def
self
.
extended
(
base
)
#:nodoc:
...
...
activemodel/lib/active_model/serializers/xml.rb
浏览文件 @
4b9dba99
...
...
@@ -6,7 +6,7 @@
module
ActiveModel
module
Serializers
# ==
Active
Model XML Serializer
# ==
\Active \
Model XML Serializer
module
Xml
extend
ActiveSupport
::
Concern
include
ActiveModel
::
Serialization
...
...
activemodel/lib/active_model/validations/absence.rb
浏览文件 @
4b9dba99
module
ActiveModel
module
Validations
# ==
Active
Model Absence Validator
# ==
\Active \
Model Absence Validator
class
AbsenceValidator
<
EachValidator
#:nodoc:
def
validate_each
(
record
,
attr_name
,
value
)
record
.
errors
.
add
(
attr_name
,
:present
,
options
)
if
value
.
present?
...
...
activemodel/lib/active_model/validator.rb
浏览文件 @
4b9dba99
...
...
@@ -127,7 +127,7 @@ def validate(record)
# in the options hash invoking the <tt>validate_each</tt> method passing in the
# record, attribute and value.
#
# All
Active
Model validations are built on top of this validator.
# All
\Active \
Model validations are built on top of this validator.
class
EachValidator
<
Validator
#:nodoc:
attr_reader
:attributes
...
...
activemodel/lib/active_model/version.rb
浏览文件 @
4b9dba99
require_relative
'gem_version'
module
ActiveModel
# Returns the version of the currently loaded
Active
Model as a <tt>Gem::Version</tt>
# Returns the version of the currently loaded
\Active \
Model as a <tt>Gem::Version</tt>
def
self
.
version
gem_version
end
...
...
activerecord/lib/active_record/querying.rb
浏览文件 @
4b9dba99
...
...
@@ -55,11 +55,12 @@ def find_by_sql(sql, binds = [])
# The use of this method should be restricted to complicated SQL queries that can't be executed
# using the ActiveRecord::Calculations class methods. Look into those before using this.
#
# ==== Parameters
# Product.count_by_sql "SELECT COUNT(*) FROM sales s, customers c WHERE s.customer_id = c.id"
# # => 12
#
#
* +sql+ - An SQL statement which should return a count query from the database, see the example below.
#
==== Parameters
#
#
Product.count_by_sql "SELECT COUNT(*) FROM sales s, customers c WHERE s.customer_id = c.id"
#
* +sql+ - An SQL statement which should return a count query from the database, see the example above.
def
count_by_sql
(
sql
)
sql
=
sanitize_conditions
(
sql
)
connection
.
select_value
(
sql
,
"
#{
name
}
Count"
).
to_i
...
...
activesupport/lib/active_support/core_ext/name_error.rb
浏览文件 @
4b9dba99
class
NameError
# Extract the name of the missing constant from the exception message.
#
# begin
# HelloWorld
# rescue NameError => e
# e.missing_name
# end
# # => "HelloWorld"
def
missing_name
if
/undefined local variable or method/
!~
message
$1
if
/((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/
=~
message
...
...
@@ -7,6 +14,13 @@ def missing_name
end
# Was this exception raised because the given name was missing?
#
# begin
# HelloWorld
# rescue NameError => e
# e.missing_name?("HelloWorld")
# end
# # => true
def
missing_name?
(
name
)
if
name
.
is_a?
Symbol
last_name
=
(
missing_name
||
''
).
split
(
'::'
).
last
...
...
activesupport/lib/active_support/core_ext/object/try.rb
浏览文件 @
4b9dba99
...
...
@@ -63,9 +63,12 @@ def try(*a, &b)
try!
(
*
a
,
&
b
)
if
a
.
empty?
||
respond_to?
(
a
.
first
)
end
# Same as #try, but will raise a NoMethodError exception if the receiver is not +nil+ and
# does not implement the tried method.
# Same as #try, but will raise a NoMethodError exception if the receiver is
# not +nil+ and does not implement the tried method.
#
# "a".try!(:upcase) # => "A"
# nil.try!(:upcase) # => nil
# 123.try!(:upcase) # => NoMethodError: undefined method `upcase' for 123:Fixnum
def
try!
(
*
a
,
&
b
)
if
a
.
empty?
&&
block_given?
if
b
.
arity
.
zero?
...
...
@@ -94,6 +97,9 @@ def try(*args)
nil
end
# Calling +try!+ on +nil+ always returns +nil+.
#
# nil.try!(:name) # => nil
def
try!
(
*
args
)
nil
end
...
...
guides/source/active_job_basics.md
浏览文件 @
4b9dba99
...
...
@@ -305,7 +305,6 @@ Active Job provides a way to catch exceptions raised during the execution of the
job:
```
ruby
class
GuestsCleanupJob
<
ActiveJob
::
Base
queue_as
:default
...
...
railties/lib/rails.rb
浏览文件 @
4b9dba99
...
...
@@ -56,10 +56,18 @@ def root
application
&&
application
.
config
.
root
end
# Returns the current Rails environment.
#
# Rails.env # => "development"
# Rails.env.development? # => true
# Rails.env.production? # => false
def
env
@_env
||=
ActiveSupport
::
StringInquirer
.
new
(
ENV
[
"RAILS_ENV"
]
||
ENV
[
"RACK_ENV"
]
||
"development"
)
end
# Sets the Rails environment.
#
# Rails.env = "staging" # => "staging"
def
env
=
(
environment
)
@_env
=
ActiveSupport
::
StringInquirer
.
new
(
environment
)
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录