Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Architecture Components

alsonkemp edited this page · 1 revision

Turbinado adds components to the usual Rails MVC organization. Components are a way to group together a Controller and Views that are tightly related and are used by other Controllers and Views. Components are very similar to Rails’ Cells. Many of the details of Components’ Controllers and Views are the same as for regular Controllers and Views so those details will be omitted here.

As an example of the creation and usage of a component, see:

  1. /App/Components/Page/Controller.hs – the Controller for the Page Components
  2. /App/Components/Page/Views/List.hs – the View for a list of Pages
  3. /App/Components/Page/Views/Show.hs – the View for a particular Page
  4. /App/Controllers/Architecture.hs – a Controller which uses the Page Component (actually, the Component is used in the View)
  5. /App/Views/Architecture/Show.hs – a View which uses the Page Component (look for the insertComponent call)

Many pages on the Turbinado website use and display Pages. Rather than having every controller understand how to load and display a Page, all of the Page load/display functionality was placed into the Page Component. Now it easy for any Controller/View to use Page functionality without having to understand Pages.


Components have:

  1. A single controller in /App/Components/ComponentName/Controller.hs.
  2. A set of Views in /App/Components/ComponentName/Views/*.hs.


Components are called in Views in this example as follows:

  <% insertComponent "Page" "ListOnly" [("pages-prefix", "architecture")] %>

This inserts a Component called “Page” and calls the “ListOnly” function of the Component. In addition, a setting is created with “pages-prefix” equal to “architecture”. This particular call inserts a list of Pages whose ids start with “architecture” and is used on the Architecture page to show a list of Architecture Pages.

Something went wrong with that request. Please try again.