2
是否有可能从另一个行动中执行一个动作?如何在Rails中执行控制器/操作?
我在寻找“重定向”和“渲染”之间的东西。我不想告诉浏览器使用'重定向'发出额外的请求,'render'只会执行视图,而不是操作。
注:我使用的是轨道3
@奔荷兰看看这个http://symfony.com/doc/current/book/controller.html#forwarding
是否有可能从另一个行动中执行一个动作?如何在Rails中执行控制器/操作?
我在寻找“重定向”和“渲染”之间的东西。我不想告诉浏览器使用'重定向'发出额外的请求,'render'只会执行视图,而不是操作。
注:我使用的是轨道3
@奔荷兰看看这个http://symfony.com/doc/current/book/controller.html#forwarding
把动作在一个lib /文件,并将其包含在两个控制器
#lib/foo_controller_includes.rb
module FooControllerIncludes
def special_edit
do_some_stuff!
render :action=>"/full/path/to/file"
end
end
#app/controllers/bar_controller.b
class BarController < ApplicationController
include FooControllerIncludes
def edit
special_edit
end
end
像部分呈现?您可以调用您在控制器操作中定义的额外功能。我不确定你想要做什么......你能更具体吗? – 2012-02-19 16:04:25
@ ben-holland我更新了帖子 – HappyDeveloper 2012-02-19 16:24:30