Rails 3渲染来自另一个控制器的动作 [英] Rails 3 render action from another controller
问题描述
我需要渲染另一个控制器动作<%=渲染 controller / index%>
,我得到这个错误
I need to render another controller action <%= render "controller/index" %>
and i get this error
缺少带有{:formats => [:html],:locale => [:en,:en],:handlers => [ :rjs,:rhtml,:rxml,:erb,:builder]}在视图路径 / path_to / app / views中
Missing partial controller/index with {:formats=>[:html], :locale=>[:en, :en], :handlers=>[:rjs, :rhtml, :rxml, :erb, :builder]} in view paths "/path_to/app/views"
我如何在视图中呈现另一个控制器动作却不发送重定向到客户端?
我尝试过
how can i render another controller action into a view but without sending an redirect to the client ? I've tried
<%=render :action => "index", :controller=>"controller" %>
但似乎不起作用。
推荐答案
尝试渲染模板:
<%= render :template => "controller/index" %>
或文件:
<%= render :template => "#{Rails.root}/app/controllers/controller/index" %>
我相信您应该通过控制器渲染它,只要它更方便:
And I believe you should render it through controller, as far as it is more convenient:
def your_action
...
render :action => :index
end
这篇关于Rails 3渲染来自另一个控制器的动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!