Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
1c4d28ba
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,发现更多精彩内容 >>
提交
1c4d28ba
编写于
6月 17, 2009
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move model naming into ActiveModel
上级
85f2f34d
变更
15
显示空白变更内容
内联
并排
Showing
15 changed file
with
31 addition
and
13 deletion
+31
-13
actionpack/test/activerecord/render_partial_with_record_identification_test.rb
...erecord/render_partial_with_record_identification_test.rb
+1
-0
actionpack/test/controller/record_identifier_test.rb
actionpack/test/controller/record_identifier_test.rb
+2
-0
actionpack/test/controller/redirect_test.rb
actionpack/test/controller/redirect_test.rb
+1
-0
actionpack/test/lib/controller/fake_models.rb
actionpack/test/lib/controller/fake_models.rb
+4
-0
actionpack/test/template/atom_feed_helper_test.rb
actionpack/test/template/atom_feed_helper_test.rb
+1
-0
actionpack/test/template/prototype_helper_test.rb
actionpack/test/template/prototype_helper_test.rb
+3
-0
actionpack/test/template/record_tag_helper_test.rb
actionpack/test/template/record_tag_helper_test.rb
+1
-0
actionpack/test/template/test_test.rb
actionpack/test/template/test_test.rb
+1
-0
actionpack/test/template/url_helper_test.rb
actionpack/test/template/url_helper_test.rb
+2
-0
activemodel/lib/active_model.rb
activemodel/lib/active_model.rb
+2
-0
activemodel/lib/active_model/naming.rb
activemodel/lib/active_model/naming.rb
+8
-8
activemodel/test/cases/naming_test.rb
activemodel/test/cases/naming_test.rb
+3
-4
activerecord/lib/active_record/base.rb
activerecord/lib/active_record/base.rb
+1
-0
activeresource/lib/active_resource/base.rb
activeresource/lib/active_resource/base.rb
+1
-0
activesupport/lib/active_support/core_ext/module.rb
activesupport/lib/active_support/core_ext/module.rb
+0
-1
未找到文件。
actionpack/test/activerecord/render_partial_with_record_identification_test.rb
浏览文件 @
1c4d28ba
...
...
@@ -126,6 +126,7 @@ def render_with_record_collection
end
class
Game
<
Struct
.
new
(
:name
,
:id
)
extend
ActiveModel
::
Naming
def
to_param
id
.
to_s
end
...
...
actionpack/test/controller/record_identifier_test.rb
浏览文件 @
1c4d28ba
require
'abstract_unit'
class
Comment
extend
ActiveModel
::
Naming
attr_reader
:id
def
save
;
@id
=
1
end
def
new_record?
;
@id
.
nil?
end
...
...
actionpack/test/controller/redirect_test.rb
浏览文件 @
1c4d28ba
...
...
@@ -4,6 +4,7 @@ class WorkshopsController < ActionController::Base
end
class
Workshop
extend
ActiveModel
::
Naming
attr_accessor
:id
,
:new_record
def
initialize
(
id
,
new_record
)
...
...
actionpack/test/lib/controller/fake_models.rb
浏览文件 @
1c4d28ba
class
Customer
<
Struct
.
new
(
:name
,
:id
)
extend
ActiveModel
::
Naming
def
to_param
id
.
to_s
end
...
...
@@ -12,6 +14,8 @@ class GoodCustomer < Customer
module
Quiz
class
Question
<
Struct
.
new
(
:name
,
:id
)
extend
ActiveModel
::
Naming
def
to_param
id
.
to_s
end
...
...
actionpack/test/template/atom_feed_helper_test.rb
浏览文件 @
1c4d28ba
require
'abstract_unit'
Scroll
=
Struct
.
new
(
:id
,
:to_param
,
:title
,
:body
,
:updated_at
,
:created_at
)
Scroll
.
extend
ActiveModel
::
Naming
class
ScrollsController
<
ActionController
::
Base
FEEDS
=
{}
...
...
actionpack/test/template/prototype_helper_test.rb
浏览文件 @
1c4d28ba
require
'abstract_unit'
Bunny
=
Struct
.
new
(
:Bunny
,
:id
)
Bunny
.
extend
ActiveModel
::
Naming
class
Author
extend
ActiveModel
::
Naming
attr_reader
:id
def
save
;
@id
=
1
end
def
new_record?
;
@id
.
nil?
end
...
...
@@ -12,6 +14,7 @@ def name
end
class
Article
extend
ActiveModel
::
Naming
attr_reader
:id
attr_reader
:author_id
def
save
;
@id
=
1
;
@author_id
=
1
end
...
...
actionpack/test/template/record_tag_helper_test.rb
浏览文件 @
1c4d28ba
require
'abstract_unit'
class
Post
extend
ActiveModel
::
Naming
def
id
45
end
...
...
actionpack/test/template/test_test.rb
浏览文件 @
1c4d28ba
...
...
@@ -41,6 +41,7 @@ def test_homepage_url
def
test_link_to_person
person
=
mock
(
:name
=>
"David"
)
person
.
class
.
extend
ActiveModel
::
Naming
expects
(
:mocha_mock_path
).
with
(
person
).
returns
(
"/people/1"
)
assert_equal
'<a href="/people/1">David</a>'
,
link_to_person
(
person
)
end
...
...
actionpack/test/template/url_helper_test.rb
浏览文件 @
1c4d28ba
...
...
@@ -494,6 +494,7 @@ def with_restful_routing
end
class
Workshop
extend
ActiveModel
::
Naming
attr_accessor
:id
,
:new_record
def
initialize
(
id
,
new_record
)
...
...
@@ -510,6 +511,7 @@ def to_s
end
class
Session
extend
ActiveModel
::
Naming
attr_accessor
:id
,
:workshop_id
,
:new_record
def
initialize
(
id
,
new_record
)
...
...
activemodel/lib/active_model.rb
浏览文件 @
1c4d28ba
...
...
@@ -29,6 +29,8 @@ module ActiveModel
autoload
:Base
,
'active_model/base'
autoload
:DeprecatedErrorMethods
,
'active_model/deprecated_error_methods'
autoload
:Errors
,
'active_model/errors'
autoload
:Name
,
'active_model/naming'
autoload
:Naming
,
'active_model/naming'
autoload
:Observer
,
'active_model/observing'
autoload
:Observing
,
'active_model/observing'
autoload
:StateMachine
,
'active_model/state_machine'
...
...
active
support/lib/active_support/core_ext/module/model_
naming.rb
→
active
model/lib/active_model/
naming.rb
浏览文件 @
1c4d28ba
require
'active_support/inflector'
module
Active
Support
class
Model
Name
<
String
module
Active
Model
class
Name
<
String
attr_reader
:singular
,
:plural
,
:element
,
:collection
,
:partial_path
alias_method
:cache_key
,
:collection
...
...
@@ -14,12 +14,12 @@ def initialize(name)
@partial_path
=
"
#{
@collection
}
/
#{
@element
}
"
.
freeze
end
end
end
class
Module
# Returns an ActiveSupport::Model
Name object for module. It can be
module
Naming
# Returns an ActiveModel::
Name object for module. It can be
# used to retrieve all kinds of naming-related information.
def
model_name
@model_name
||=
ActiveSupport
::
ModelName
.
new
(
name
)
@_model_name
||=
ActiveModel
::
Name
.
new
(
name
)
end
end
end
active
support/test/core_ext/module/model_
naming_test.rb
→
active
model/test/cases/
naming_test.rb
浏览文件 @
1c4d28ba
require
'abstract_unit'
require
'active_support/core_ext/module/model_naming'
require
'cases/helper'
class
Model
NamingTest
<
Test
::
Unit
::
TestCase
class
NamingTest
<
Test
::
Unit
::
TestCase
def
setup
@model_name
=
Active
Support
::
Model
Name
.
new
(
'Post::TrackBack'
)
@model_name
=
Active
Model
::
Name
.
new
(
'Post::TrackBack'
)
end
def
test_singular
...
...
activerecord/lib/active_record/base.rb
浏览文件 @
1c4d28ba
...
...
@@ -3145,6 +3145,7 @@ def clone_attribute_value(reader_method, attribute_name)
end
Base
.
class_eval
do
extend
ActiveModel
::
Naming
extend
QueryCache
::
ClassMethods
include
Validations
include
Locking
::
Optimistic
,
Locking
::
Pessimistic
...
...
activeresource/lib/active_resource/base.rb
浏览文件 @
1c4d28ba
...
...
@@ -1086,6 +1086,7 @@ def method_missing(method_symbol, *arguments) #:nodoc:
end
class
Base
extend
ActiveModel
::
Naming
include
CustomMethods
,
Validations
end
end
activesupport/lib/active_support/core_ext/module.rb
浏览文件 @
1c4d28ba
...
...
@@ -7,5 +7,4 @@
require
'active_support/core_ext/module/attr_accessor_with_default'
require
'active_support/core_ext/module/delegation'
require
'active_support/core_ext/module/loading'
require
'active_support/core_ext/module/model_naming'
require
'active_support/core_ext/module/synchronization'
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录