我知道它完全反对MVC,但无论如何必须以这种方式完成。所以我需要这样的东西:
app/controllers/controller_a.rb
class ControllerA < ApplicationController
def index
some_code
end
end
app/controllers/controller_b.rb
class ControllerB < ApplicationController
def other_index
@var = 'example'
end
end
app/views/controller_b/other_index.html.erb
<%= @var %>
所以,当我访问URL localhost:3000 / controller_as / index(我的意思是,对应于controller_a.rb的索引操作的那个)时,我必须在浏览器中获取下一个:
example
我的意思是,我必须执行controller_b other_index操作并渲染other_index.html.erb
我会感激任何帮助。感谢。
答案 0 :(得分:0)
您需要将controller_b的逻辑重构为模型。另一种方法是使用AJAX从controller_a
的索引页面调用controller_b