Skip to content
Emerson "Duke" Almeida edited this page Jul 19, 2019 · 10 revisions

Views Inheritance

Sometimes just DRY the controllers is not enough, if you need to DRY up your views, a lot of the resources often share the same views, wouldn't it be nice to have view files DRY'ed too? You can!

In Rails 3.1, this will be a Rails feature, but if you need to use a previous version, there are currently three projects do just that:

Inherited Resources Views

Inherited Resources Views is an extremely easy to use plugin to DRY the views associated with your inherited resources controllers. It is library-agnostic (it only depends on Inherited Resources) and it supports generating both erb and haml templates.

Source: http://github.com/fredwu/inherited_resources_views

NOTE: This project is marked as abandoned on the GitHub page (http://stillmaintained.com/fredwu/inherited_resources_views)

Inherited Views

Inherited Views is a thin addition to the Inherited Resources project adding default html views which can be later customized on a per controller basis or globally for your rails app. It depends on Inherited Resources, Formtastic and WillPaginate.

Source: http://github.com/gregbell/inherited_views

Render Inheritable

Render Inheritable allows one to generally inherit or override single templates for controller hierarchies. If a template is not found in the current view folder, it is looked up in the parent controller's view folder. There are no other dependencies except for Rails 3.

Source: http://github.com/codez/render_inheritable

Clone this wiki locally