Mixin in ERB Templates

Hi All,

I have some ERB .rhtml templates in my rails CMS app. The user selects
a template for each page through the CMS administration UI. So the list
of available templates is presented in a drop-down.

I don’t want to create a ‘template’ model which sits in my DB as it is
overkill. What I want to do is somehow define meta data about each
template (namely a title and description) as some class variables
inside the ERB .rhtml templates such as:

require ‘registerable_asset’
include RegisterableAsset
register ‘Name of Template’
description ‘This template is a default template’

... rest of template ...

So I’ve created a module (registerable_asset) which appends these
features as class variables and tried to include this in the template
file using the standard (include …), but I get an error:

undefined method `include’ for #<#Class:0x256a8dc:0x256a8b4>

I assume that I am putting the ‘include’ statement in the wrong place
but I’m not sure where to put it. Does anyone have any suggestions?

Many Thanks

Mark D.

Put this file in the lib directory and Rails will find the class
automatically. Nor require required. :wink:

Thanks, I didn’t know that. However, it seems to be the ‘include’
statement that is causing trouble…