开发者

How to call views from multiple controllers?

开发者 https://www.devze.com 2023-01-19 08:09 出处:网络
I have multiple controllers having their own views (Index.html). Now, I want to create another controller (Say \"Welcome\") and I want to include views of all other controllers into the view of \"Welc

I have multiple controllers having their own views (Index.html). Now, I want to create another controller (Say "Welcome") and I want to include views of all other controllers into the view of "Welcome", so that all the views are available on single page and welcome page gets updated automatically whenever I change any in开发者_运维知识库dividual index page of any controller.


If you whant to have view of one controller inside other controllers view you should render first view as a file <%=render 'controller/action'%> and in such case you must assign all variables that are neccessary for building this view(all variables that are assigned inside action) But you'll render this view inside your controllers layout and if you have some filters you also must apply them to the new controller

0

精彩评论

暂无评论...
验证码 换一张
取 消