在多个控制器之间共享视图

时间:2013-08-01 19:18:16

标签: ruby-on-rails web

我无法在Ruby on Rails应用程序中的多个控制器之间共享视图。 请帮忙。

2 个答案:

答案 0 :(得分:0)

您可以在尝试渲染其他视图的视图中使用此视图

abc - The name of the folder in which the other view exists (views/abc/view_name.html.erb)
xyz - The name of the view

<%= render :template "abc/xyz" %>

答案 1 :(得分:0)

你甚至可以在控制器的action.eg中使用partials或显式渲染另一个模板: -

def UsersController < ApplicationController

  def index
    @records = User.all
    render '/products/index' # instead of user's index i rendered product's index template
  end

end
相关问题