Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
c2fa5360
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,发现更多精彩内容 >>
提交
c2fa5360
编写于
10月 10, 2016
作者:
R
Rafael França
提交者:
GitHub
10月 10, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #26755 from rafaelfranca/deprecations
Remove deprecations in Active Model, Action View and Active Job
上级
36f6ab2d
6a78e0ec
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
25 addition
and
300 deletion
+25
-300
actionview/CHANGELOG.md
actionview/CHANGELOG.md
+4
-0
actionview/lib/action_view/template/error.rb
actionview/lib/action_view/template/error.rb
+1
-11
activejob/CHANGELOG.md
activejob/CHANGELOG.md
+8
-0
activejob/lib/active_job/arguments.rb
activejob/lib/active_job/arguments.rb
+1
-13
activejob/lib/active_job/queue_adapter.rb
activejob/lib/active_job/queue_adapter.rb
+0
-10
activejob/test/cases/queue_adapter_test.rb
activejob/test/cases/queue_adapter_test.rb
+0
-13
activemodel/CHANGELOG.md
activemodel/CHANGELOG.md
+10
-0
activemodel/lib/active_model/errors.rb
activemodel/lib/active_model/errors.rb
+0
-87
activemodel/lib/active_model/validations/length.rb
activemodel/lib/active_model/validations/length.rb
+1
-34
activemodel/test/cases/errors_test.rb
activemodel/test/cases/errors_test.rb
+0
-92
activemodel/test/cases/validations/length_validation_test.rb
activemodel/test/cases/validations/length_validation_test.rb
+0
-36
activemodel/test/models/topic.rb
activemodel/test/models/topic.rb
+0
-4
未找到文件。
actionview/CHANGELOG.md
浏览文件 @
c2fa5360
*
Removed deprecated
`#original_exception`
in
`ActionView::Template::Error`
.
*Rafael Mendonça França*
*
Render now accepts any keys for locals, including reserved words
*
Render now accepts any keys for locals, including reserved words
Only locals with valid variable names get set directly. Others
Only locals with valid variable names get set directly. Others
...
...
actionview/lib/action_view/template/error.rb
浏览文件 @
c2fa5360
...
@@ -63,23 +63,13 @@ class Error < ActionViewError #:nodoc:
...
@@ -63,23 +63,13 @@ class Error < ActionViewError #:nodoc:
# Override to prevent #cause resetting during re-raise.
# Override to prevent #cause resetting during re-raise.
attr_reader
:cause
attr_reader
:cause
def
initialize
(
template
,
original_exception
=
nil
)
def
initialize
(
template
)
if
original_exception
ActiveSupport
::
Deprecation
.
warn
(
"Passing #original_exception is deprecated and has no effect. "
\
"Exceptions will automatically capture the original exception."
,
caller
)
end
super
(
$!
.
message
)
super
(
$!
.
message
)
set_backtrace
(
$!
.
backtrace
)
set_backtrace
(
$!
.
backtrace
)
@cause
=
$!
@cause
=
$!
@template
,
@sub_templates
=
template
,
nil
@template
,
@sub_templates
=
template
,
nil
end
end
def
original_exception
ActiveSupport
::
Deprecation
.
warn
(
"#original_exception is deprecated. Use #cause instead."
,
caller
)
cause
end
def
file_name
def
file_name
@template
.
identifier
@template
.
identifier
end
end
...
...
activejob/CHANGELOG.md
浏览文件 @
c2fa5360
*
Removed deprecated support to passing the adapter class to
`.queue_adapter`
.
*Rafael Mendonça França*
*
Removed deprecated
`#original_exception`
in
`ActiveJob::DeserializationError`
.
*Rafael Mendonça França*
*
Added instance variable
`@queue`
to JobWrapper.
*
Added instance variable
`@queue`
to JobWrapper.
This will fix issues in [resque-scheduler](https://github.com/resque/resque-scheduler) `#job_to_hash` method,
This will fix issues in [resque-scheduler](https://github.com/resque/resque-scheduler) `#job_to_hash` method,
...
...
activejob/lib/active_job/arguments.rb
浏览文件 @
c2fa5360
...
@@ -5,22 +5,10 @@ module ActiveJob
...
@@ -5,22 +5,10 @@ module ActiveJob
#
#
# Wraps the original exception raised as +cause+.
# Wraps the original exception raised as +cause+.
class
DeserializationError
<
StandardError
class
DeserializationError
<
StandardError
def
initialize
(
e
=
nil
)
#:nodoc:
def
initialize
#:nodoc:
if
e
ActiveSupport
::
Deprecation
.
warn
(
"Passing #original_exception is deprecated and has no effect. "
\
"Exceptions will automatically capture the original exception."
,
caller
)
end
super
(
"Error while trying to deserialize arguments:
#{
$!
.
message
}
"
)
super
(
"Error while trying to deserialize arguments:
#{
$!
.
message
}
"
)
set_backtrace
$!
.
backtrace
set_backtrace
$!
.
backtrace
end
end
# The original exception that was raised during deserialization of job
# arguments.
def
original_exception
ActiveSupport
::
Deprecation
.
warn
(
"#original_exception is deprecated. Use #cause instead."
,
caller
)
cause
end
end
end
# Raised when an unsupported argument type is set as a job argument. We
# Raised when an unsupported argument type is set as a job argument. We
...
...
activejob/lib/active_job/queue_adapter.rb
浏览文件 @
c2fa5360
...
@@ -37,12 +37,6 @@ def interpret_adapter(name_or_adapter_or_class)
...
@@ -37,12 +37,6 @@ def interpret_adapter(name_or_adapter_or_class)
else
else
if
queue_adapter?
(
name_or_adapter_or_class
)
if
queue_adapter?
(
name_or_adapter_or_class
)
name_or_adapter_or_class
name_or_adapter_or_class
elsif
queue_adapter_class?
(
name_or_adapter_or_class
)
ActiveSupport
::
Deprecation
.
warn
"Passing an adapter class is deprecated "
\
"and will be removed in Rails 5.1. Please pass an adapter name "
\
"(.queue_adapter = :
#{
name_or_adapter_or_class
.
name
.
demodulize
.
remove
(
'Adapter'
).
underscore
}
) "
\
"or an instance (.queue_adapter =
#{
name_or_adapter_or_class
.
name
}
.new) instead."
name_or_adapter_or_class
.
new
else
else
raise
ArgumentError
raise
ArgumentError
end
end
...
@@ -54,10 +48,6 @@ def interpret_adapter(name_or_adapter_or_class)
...
@@ -54,10 +48,6 @@ def interpret_adapter(name_or_adapter_or_class)
def
queue_adapter?
(
object
)
def
queue_adapter?
(
object
)
QUEUE_ADAPTER_METHODS
.
all?
{
|
meth
|
object
.
respond_to?
(
meth
)
}
QUEUE_ADAPTER_METHODS
.
all?
{
|
meth
|
object
.
respond_to?
(
meth
)
}
end
end
def
queue_adapter_class?
(
object
)
object
.
is_a?
(
Class
)
&&
QUEUE_ADAPTER_METHODS
.
all?
{
|
meth
|
object
.
public_method_defined?
(
meth
)
}
end
end
end
end
end
end
end
activejob/test/cases/queue_adapter_test.rb
浏览文件 @
c2fa5360
...
@@ -20,19 +20,6 @@ class QueueAdapterTest < ActiveJob::TestCase
...
@@ -20,19 +20,6 @@ class QueueAdapterTest < ActiveJob::TestCase
assert_raises
(
ArgumentError
)
{
ActiveJob
::
Base
.
queue_adapter
=
Mutex
.
new
}
assert_raises
(
ArgumentError
)
{
ActiveJob
::
Base
.
queue_adapter
=
Mutex
.
new
}
end
end
test
"should warn on passing an adapter class"
do
klass
=
Class
.
new
do
def
self
.
name
"fake"
end
def
enqueue
(
*
);
end
def
enqueue_at
(
*
);
end
end
assert_deprecated
{
ActiveJob
::
Base
.
queue_adapter
=
klass
}
end
test
"should allow overriding the queue_adapter at the child class level without affecting the parent or its sibling"
do
test
"should allow overriding the queue_adapter at the child class level without affecting the parent or its sibling"
do
base_queue_adapter
=
ActiveJob
::
Base
.
queue_adapter
base_queue_adapter
=
ActiveJob
::
Base
.
queue_adapter
...
...
activemodel/CHANGELOG.md
浏览文件 @
c2fa5360
*
Removed deprecated
`:tokenizer`
in the length validator.
*Rafael Mendonça França*
*
Removed deprecated methods in
`ActiveModel::Errors`
.
`#get`, `#set`, `[]=`, `add_on_empty` and `add_on_blank`.
*Rafael Mendonça França*
Please check
[
5-0-stable
](
https://github.com/rails/rails/blob/5-0-stable/activemodel/CHANGELOG.md
)
for previous changes.
Please check
[
5-0-stable
](
https://github.com/rails/rails/blob/5-0-stable/activemodel/CHANGELOG.md
)
for previous changes.
activemodel/lib/active_model/errors.rb
浏览文件 @
c2fa5360
...
@@ -115,36 +115,6 @@ def include?(attribute)
...
@@ -115,36 +115,6 @@ def include?(attribute)
alias
:has_key?
:include?
alias
:has_key?
:include?
alias
:key?
:include?
alias
:key?
:include?
# Get messages for +key+.
#
# person.errors.messages # => {:name=>["cannot be nil"]}
# person.errors.get(:name) # => ["cannot be nil"]
# person.errors.get(:age) # => []
def
get
(
key
)
ActiveSupport
::
Deprecation
.
warn
(
<<-
MESSAGE
.
squish
)
ActiveModel::Errors#get is deprecated and will be removed in Rails 5.1.
To achieve the same use model.errors[:
#{
key
}
].
MESSAGE
messages
[
key
]
end
# Set messages for +key+ to +value+.
#
# person.errors[:name] # => ["cannot be nil"]
# person.errors.set(:name, ["can't be nil"])
# person.errors[:name] # => ["can't be nil"]
def
set
(
key
,
value
)
ActiveSupport
::
Deprecation
.
warn
(
<<-
MESSAGE
.
squish
)
ActiveModel::Errors#set is deprecated and will be removed in Rails 5.1.
Use model.errors.add(:
#{
key
}
,
#{
value
.
inspect
}
) instead.
MESSAGE
messages
[
key
]
=
value
end
# Delete messages for +key+. Returns the deleted messages.
# Delete messages for +key+. Returns the deleted messages.
#
#
# person.errors[:name] # => ["cannot be nil"]
# person.errors[:name] # => ["cannot be nil"]
...
@@ -173,20 +143,6 @@ def [](attribute)
...
@@ -173,20 +143,6 @@ def [](attribute)
messages
[
attribute
.
to_sym
]
messages
[
attribute
.
to_sym
]
end
end
# Adds to the supplied attribute the supplied error message.
#
# person.errors[:name] = "must be set"
# person.errors[:name] # => ['must be set']
def
[]=
(
attribute
,
error
)
ActiveSupport
::
Deprecation
.
warn
(
<<-
MESSAGE
.
squish
)
ActiveModel::Errors#[]= is deprecated and will be removed in Rails 5.1.
Use model.errors.add(:
#{
attribute
}
,
#{
error
.
inspect
}
) instead.
MESSAGE
messages
[
attribute
.
to_sym
]
<<
error
end
# Iterates through each error key, value pair in the error messages hash.
# Iterates through each error key, value pair in the error messages hash.
# Yields the attribute and the error for that attribute. If the attribute
# Yields the attribute and the error for that attribute. If the attribute
# has more than one error message, yields once for each error message.
# has more than one error message, yields once for each error message.
...
@@ -338,49 +294,6 @@ def add(attribute, message = :invalid, options = {})
...
@@ -338,49 +294,6 @@ def add(attribute, message = :invalid, options = {})
messages
[
attribute
.
to_sym
]
<<
message
messages
[
attribute
.
to_sym
]
<<
message
end
end
# Will add an error message to each of the attributes in +attributes+
# that is empty.
#
# person.errors.add_on_empty(:name)
# person.errors.messages
# # => {:name=>["can't be empty"]}
def
add_on_empty
(
attributes
,
options
=
{})
ActiveSupport
::
Deprecation
.
warn
(
<<-
MESSAGE
.
squish
)
ActiveModel::Errors#add_on_empty is deprecated and will be removed in Rails 5.1.
To achieve the same use:
errors.add(attribute, :empty, options) if value.nil? || value.empty?
MESSAGE
Array
(
attributes
).
each
do
|
attribute
|
value
=
@base
.
send
(
:read_attribute_for_validation
,
attribute
)
is_empty
=
value
.
respond_to?
(
:empty?
)
?
value
.
empty?
:
false
add
(
attribute
,
:empty
,
options
)
if
value
.
nil?
||
is_empty
end
end
# Will add an error message to each of the attributes in +attributes+ that
# is blank (using Object#blank?).
#
# person.errors.add_on_blank(:name)
# person.errors.messages
# # => {:name=>["can't be blank"]}
def
add_on_blank
(
attributes
,
options
=
{})
ActiveSupport
::
Deprecation
.
warn
(
<<-
MESSAGE
.
squish
)
ActiveModel::Errors#add_on_blank is deprecated and will be removed in Rails 5.1.
To achieve the same use:
errors.add(attribute, :blank, options) if value.blank?
MESSAGE
Array
(
attributes
).
each
do
|
attribute
|
value
=
@base
.
send
(
:read_attribute_for_validation
,
attribute
)
add
(
attribute
,
:blank
,
options
)
if
value
.
blank?
end
end
# Returns +true+ if an error on the attribute with the given message is
# Returns +true+ if an error on the attribute with the given message is
# present, or +false+ otherwise. +message+ is treated the same as for +add+.
# present, or +false+ otherwise. +message+ is treated the same as for +add+.
#
#
...
...
activemodel/lib/active_model/validations/length.rb
浏览文件 @
c2fa5360
...
@@ -6,7 +6,7 @@ class LengthValidator < EachValidator # :nodoc:
...
@@ -6,7 +6,7 @@ class LengthValidator < EachValidator # :nodoc:
MESSAGES
=
{
is: :wrong_length
,
minimum: :too_short
,
maximum: :too_long
}.
freeze
MESSAGES
=
{
is: :wrong_length
,
minimum: :too_short
,
maximum: :too_long
}.
freeze
CHECKS
=
{
is: :==
,
minimum:
:
>=
,
maximum: :<=
}.
freeze
CHECKS
=
{
is: :==
,
minimum:
:
>=
,
maximum: :<=
}.
freeze
RESERVED_OPTIONS
=
[
:minimum
,
:maximum
,
:within
,
:is
,
:to
kenizer
,
:to
o_short
,
:too_long
]
RESERVED_OPTIONS
=
[
:minimum
,
:maximum
,
:within
,
:is
,
:too_short
,
:too_long
]
def
initialize
(
options
)
def
initialize
(
options
)
if
range
=
(
options
.
delete
(
:in
)
||
options
.
delete
(
:within
))
if
range
=
(
options
.
delete
(
:in
)
||
options
.
delete
(
:within
))
...
@@ -18,27 +18,6 @@ def initialize(options)
...
@@ -18,27 +18,6 @@ def initialize(options)
options
[
:minimum
]
=
1
options
[
:minimum
]
=
1
end
end
if
options
[
:tokenizer
]
ActiveSupport
::
Deprecation
.
warn
(
<<-
EOS
.
strip_heredoc
)
The `:tokenizer` option is deprecated, and will be removed in Rails 5.1.
You can achieve the same functionality by defining an instance method
with the value that you want to validate the length of. For example,
validates_length_of :essay, minimum: 100,
tokenizer: ->(str) { str.scan(/
\w
+/) }
should be written as
validates_length_of :words_in_essay, minimum: 100
private
def words_in_essay
essay.scan(/
\w
+/)
end
EOS
end
super
super
end
end
...
@@ -59,7 +38,6 @@ def check_validity!
...
@@ -59,7 +38,6 @@ def check_validity!
end
end
def
validate_each
(
record
,
attribute
,
value
)
def
validate_each
(
record
,
attribute
,
value
)
value
=
tokenize
(
record
,
value
)
value_length
=
value
.
respond_to?
(
:length
)
?
value
.
length
:
value
.
to_s
.
length
value_length
=
value
.
respond_to?
(
:length
)
?
value
.
length
:
value
.
to_s
.
length
errors_options
=
options
.
except
(
*
RESERVED_OPTIONS
)
errors_options
=
options
.
except
(
*
RESERVED_OPTIONS
)
...
@@ -80,17 +58,6 @@ def validate_each(record, attribute, value)
...
@@ -80,17 +58,6 @@ def validate_each(record, attribute, value)
end
end
private
private
def
tokenize
(
record
,
value
)
tokenizer
=
options
[
:tokenizer
]
if
tokenizer
&&
value
.
kind_of?
(
String
)
if
tokenizer
.
kind_of?
(
Proc
)
tokenizer
.
call
(
value
)
elsif
record
.
respond_to?
(
tokenizer
)
record
.
send
(
tokenizer
,
value
)
end
end
||
value
end
def
skip_nil_check?
(
key
)
def
skip_nil_check?
(
key
)
key
==
:maximum
&&
options
[
:allow_nil
].
nil?
&&
options
[
:allow_blank
].
nil?
key
==
:maximum
&&
options
[
:allow_nil
].
nil?
&&
options
[
:allow_blank
].
nil?
end
end
...
...
activemodel/test/cases/errors_test.rb
浏览文件 @
c2fa5360
...
@@ -79,24 +79,6 @@ def test_no_key
...
@@ -79,24 +79,6 @@ def test_no_key
assert
person
.
errors
.
empty?
assert
person
.
errors
.
empty?
end
end
test
"get returns the errors for the provided key"
do
errors
=
ActiveModel
::
Errors
.
new
(
self
)
errors
[
:foo
]
<<
"omg"
assert_deprecated
do
assert_equal
[
"omg"
],
errors
.
get
(
:foo
)
end
end
test
"sets the error with the provided key"
do
errors
=
ActiveModel
::
Errors
.
new
(
self
)
assert_deprecated
do
errors
.
set
(
:foo
,
"omg"
)
end
assert_equal
({
foo:
"omg"
},
errors
.
messages
)
end
test
"error access is indifferent"
do
test
"error access is indifferent"
do
errors
=
ActiveModel
::
Errors
.
new
(
self
)
errors
=
ActiveModel
::
Errors
.
new
(
self
)
errors
[
:foo
]
<<
"omg"
errors
[
:foo
]
<<
"omg"
...
@@ -142,14 +124,6 @@ def test_no_key
...
@@ -142,14 +124,6 @@ def test_no_key
assert_equal
[
"cannot be nil"
],
person
.
errors
[
:name
]
assert_equal
[
"cannot be nil"
],
person
.
errors
[
:name
]
end
end
test
"assign error"
do
person
=
Person
.
new
assert_deprecated
do
person
.
errors
[
:name
]
=
"should not be nil"
end
assert_equal
[
"should not be nil"
],
person
.
errors
[
:name
]
end
test
"add an error message on a specific attribute"
do
test
"add an error message on a specific attribute"
do
person
=
Person
.
new
person
=
Person
.
new
person
.
errors
.
add
(
:name
,
"cannot be blank"
)
person
.
errors
.
add
(
:name
,
"cannot be blank"
)
...
@@ -320,72 +294,6 @@ def test_no_key
...
@@ -320,72 +294,6 @@ def test_no_key
}
}
end
end
test
"add_on_empty generates message"
do
person
=
Person
.
new
assert_called_with
(
person
.
errors
,
:generate_message
,
[
:name
,
:empty
,
{}])
do
assert_deprecated
do
person
.
errors
.
add_on_empty
:name
end
end
end
test
"add_on_empty generates message for multiple attributes"
do
person
=
Person
.
new
expected_calls
=
[
[
:name
,
:empty
,
{}],
[
:age
,
:empty
,
{}]
]
assert_called_with
(
person
.
errors
,
:generate_message
,
expected_calls
)
do
assert_deprecated
do
person
.
errors
.
add_on_empty
[
:name
,
:age
]
end
end
end
test
"add_on_empty generates message with custom default message"
do
person
=
Person
.
new
assert_called_with
(
person
.
errors
,
:generate_message
,
[
:name
,
:empty
,
{
message:
"custom"
}])
do
assert_deprecated
do
person
.
errors
.
add_on_empty
:name
,
message:
"custom"
end
end
end
test
"add_on_empty generates message with empty string value"
do
person
=
Person
.
new
person
.
name
=
""
assert_called_with
(
person
.
errors
,
:generate_message
,
[
:name
,
:empty
,
{}])
do
assert_deprecated
do
person
.
errors
.
add_on_empty
:name
end
end
end
test
"add_on_blank generates message"
do
person
=
Person
.
new
assert_called_with
(
person
.
errors
,
:generate_message
,
[
:name
,
:blank
,
{}])
do
assert_deprecated
do
person
.
errors
.
add_on_blank
:name
end
end
end
test
"add_on_blank generates message for multiple attributes"
do
person
=
Person
.
new
expected_calls
=
[
[
:name
,
:blank
,
{}],
[
:age
,
:blank
,
{}]
]
assert_called_with
(
person
.
errors
,
:generate_message
,
expected_calls
)
do
assert_deprecated
do
person
.
errors
.
add_on_blank
[
:name
,
:age
]
end
end
end
test
"add_on_blank generates message with custom default message"
do
person
=
Person
.
new
assert_called_with
(
person
.
errors
,
:generate_message
,
[
:name
,
:blank
,
{
message:
"custom"
}])
do
assert_deprecated
do
person
.
errors
.
add_on_blank
:name
,
message:
"custom"
end
end
end
test
"details returns added error detail"
do
test
"details returns added error detail"
do
person
=
Person
.
new
person
=
Person
.
new
person
.
errors
.
add
(
:name
,
:invalid
)
person
.
errors
.
add
(
:name
,
:invalid
)
...
...
activemodel/test/cases/validations/length_validation_test.rb
浏览文件 @
c2fa5360
...
@@ -318,42 +318,6 @@ def test_validates_length_of_using_is_utf8
...
@@ -318,42 +318,6 @@ def test_validates_length_of_using_is_utf8
assert_equal
[
"is the wrong length (should be 5 characters)"
],
t
.
errors
[
"title"
]
assert_equal
[
"is the wrong length (should be 5 characters)"
],
t
.
errors
[
"title"
]
end
end
def
test_validates_length_of_with_block
assert_deprecated
do
Topic
.
validates_length_of
(
:content
,
minimum:
5
,
too_short:
"Your essay must be at least %{count} words."
,
tokenizer:
lambda
{
|
str
|
str
.
scan
(
/\w+/
)
},
)
end
t
=
Topic
.
new
(
content:
"this content should be long enough"
)
assert
t
.
valid?
t
.
content
=
"not long enough"
assert
t
.
invalid?
assert
t
.
errors
[
:content
].
any?
assert_equal
[
"Your essay must be at least 5 words."
],
t
.
errors
[
:content
]
end
def
test_validates_length_of_with_symbol
assert_deprecated
do
Topic
.
validates_length_of
(
:content
,
minimum:
5
,
too_short:
"Your essay must be at least %{count} words."
,
tokenizer: :my_word_tokenizer
,
)
end
t
=
Topic
.
new
(
content:
"this content should be long enough"
)
assert
t
.
valid?
t
.
content
=
"not long enough"
assert
t
.
invalid?
assert
t
.
errors
[
:content
].
any?
assert_equal
[
"Your essay must be at least 5 words."
],
t
.
errors
[
:content
]
end
def
test_validates_length_of_for_integer
def
test_validates_length_of_for_integer
Topic
.
validates_length_of
(
:approved
,
is:
4
)
Topic
.
validates_length_of
(
:approved
,
is:
4
)
...
...
activemodel/test/models/topic.rb
浏览文件 @
c2fa5360
...
@@ -36,8 +36,4 @@ def my_validation
...
@@ -36,8 +36,4 @@ def my_validation
def
my_validation_with_arg
(
attr
)
def
my_validation_with_arg
(
attr
)
errors
.
add
attr
,
"is missing"
unless
send
(
attr
)
errors
.
add
attr
,
"is missing"
unless
send
(
attr
)
end
end
def
my_word_tokenizer
(
str
)
str
.
scan
(
/\w+/
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录