How to Render Another Controller in Ruby
An application written in the Ruby on Rails programming language uses MVC architecture, short for "models, views and controllers." A model controls how the app stores data, a view displays the data and a controller holds programming logic that connects and manipulates the data for the view. Generally, each segment of your application, such as users, products or profiles, has its own model, views and controller. You can load one set of views through another controller with the render command.
Instructions
-
-
1
Open the controller with which you want to work in a text editing program such as Notepad, e or TextMate.
-
2
Type the following line of code within the action that you want to render the other controller's view:
render 'controller/view'
Replace "controller" with the name of the other controller. Replace "view" with the name of the view you want to load. For example, to load the "show" view for a "book" you would type:
render 'books/show'
-
-
3
Press "Ctrl" and "S" to save your changes.
-
1