ruby-on-rails – 从另一个控制器渲染控制器动作

我认为代码更加明确

选项A

class RedirectController < ApplicationController
  def index
    redirect_to :controller => 'posts', :action => 'show', :id => 1
    # it works
  end
end

选项B

class RedirectController < ApplicationController
  def index
    render :controller => 'posts', :action => 'show', :id => 1
    # it doesn't work
  end
end

(B)可以在另一个控制器中加载另一个动作吗? (而不只是视图)怎么样?
谢谢

您好,尝试渲染“帖子/显示”或渲染:template => “的帖子/秀”
翻译自:https://stackoverflow.com/questions/3370234/render-controller-action-from-another-controller

转载注明原文:ruby-on-rails – 从另一个控制器渲染控制器动作