Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
0eedfec8
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,发现更多精彩内容 >>
提交
0eedfec8
编写于
12月 08, 2012
作者:
C
Carlos Antonio da Silva
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #8459 from frodsan/explicit!
use :only instead of :except callback option in the controller template
上级
69163cca
cd526fe4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
19 deletion
+14
-19
railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
...erators/rails/scaffold_controller/templates/controller.rb
+2
-3
railties/test/generators/scaffold_generator_test.rb
railties/test/generators/scaffold_generator_test.rb
+12
-16
未找到文件。
railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
浏览文件 @
0eedfec8
...
...
@@ -4,8 +4,8 @@
<% end -%>
<% module_namespacing do -%>
class <%= controller_class_name %>Controller < ApplicationController
before_action :set_<%= singular_table_name %>,
except: [ :index, :new, :create
]
before_action :set_<%= singular_table_name %>,
only: [ :show, :edit, :update, :destroy
]
# GET <%= route_url %>
# GET <%= route_url %>.json
def index
...
...
@@ -82,7 +82,6 @@ def destroy
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_<%= singular_table_name %>
...
...
railties/test/generators/scaffold_generator_test.rb
浏览文件 @
0eedfec8
...
...
@@ -30,17 +30,13 @@ def test_scaffold_on_invoke
assert_match
(
/@product_lines = ProductLine\.all/
,
m
)
end
assert_instance_method
:show
,
content
do
|
m
|
assert_match
(
/@product_line = ProductLine\.find\(params\[:id\]\)/
,
m
)
end
assert_instance_method
:show
,
content
assert_instance_method
:new
,
content
do
|
m
|
assert_match
(
/@product_line = ProductLine\.new/
,
m
)
end
assert_instance_method
:edit
,
content
do
|
m
|
assert_match
(
/@product_line = ProductLine\.find\(params\[:id\]\)/
,
m
)
end
assert_instance_method
:edit
,
content
assert_instance_method
:create
,
content
do
|
m
|
assert_match
(
/@product_line = ProductLine\.new\(product_line_params\)/
,
m
)
...
...
@@ -49,15 +45,17 @@ def test_scaffold_on_invoke
end
assert_instance_method
:update
,
content
do
|
m
|
assert_match
(
/@product_line = ProductLine\.find\(params\[:id\]\)/
,
m
)
assert_match
(
/@product_line\.update_attributes\(product_line_params\)/
,
m
)
assert_match
(
/@product_line\.errors/
,
m
)
end
assert_instance_method
:destroy
,
content
do
|
m
|
assert_match
(
/@product_line = ProductLine\.find\(params\[:id\]\)/
,
m
)
assert_match
(
/@product_line\.destroy/
,
m
)
end
assert_instance_method
:set_product_line
,
content
do
|
m
|
assert_match
(
/@product_line = ProductLine\.find\(params\[:id\]\)/
,
m
)
end
end
assert_file
"test/controllers/product_lines_controller_test.rb"
do
|
test
|
...
...
@@ -149,17 +147,13 @@ def test_scaffold_with_namespace_on_invoke
assert_match
(
/@admin_roles = Admin::Role\.all/
,
m
)
end
assert_instance_method
:show
,
content
do
|
m
|
assert_match
(
/@admin_role = Admin::Role\.find\(params\[:id\]\)/
,
m
)
end
assert_instance_method
:show
,
content
assert_instance_method
:new
,
content
do
|
m
|
assert_match
(
/@admin_role = Admin::Role\.new/
,
m
)
end
assert_instance_method
:edit
,
content
do
|
m
|
assert_match
(
/@admin_role = Admin::Role\.find\(params\[:id\]\)/
,
m
)
end
assert_instance_method
:edit
,
content
assert_instance_method
:create
,
content
do
|
m
|
assert_match
(
/@admin_role = Admin::Role\.new\(admin_role_params\)/
,
m
)
...
...
@@ -168,15 +162,17 @@ def test_scaffold_with_namespace_on_invoke
end
assert_instance_method
:update
,
content
do
|
m
|
assert_match
(
/@admin_role = Admin::Role\.find\(params\[:id\]\)/
,
m
)
assert_match
(
/@admin_role\.update_attributes\(admin_role_params\)/
,
m
)
assert_match
(
/@admin_role\.errors/
,
m
)
end
assert_instance_method
:destroy
,
content
do
|
m
|
assert_match
(
/@admin_role = Admin::Role\.find\(params\[:id\]\)/
,
m
)
assert_match
(
/@admin_role\.destroy/
,
m
)
end
assert_instance_method
:set_admin_role
,
content
do
|
m
|
assert_match
(
/@admin_role = Admin::Role\.find\(params\[:id\]\)/
,
m
)
end
end
assert_file
"test/controllers/admin/roles_controller_test.rb"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录