views:

404

answers:

2

I wonder if there is a way for me to store ruby on rails view files into database store and have that fetched directly from there. The reason is I want to create a CMS with all the user data stored in database, so I would like to have the template stored in database but still retain the whole ActionView mechanism.

+1  A: 

Solution for your problem is the Template Engine in Rails .

Liquid template engine is an extraction from the e-commerce system Shopify. Shopify powers many thousands of e-commerce stores which all call for unique designs.

MasterView : Alternative Template Engine in Rails .

Choose the one which suits your requirement .

Hope this helps !

YetAnotherCoder
I tried liquid, don't like it. Unless security is the main concern, liquid is a bad thing to put in your hands when you are developing website.MasterView haven't tried, will take a look, but my question ultimately is the template storage abstraction, not sure if there is a mechanism for that.
goodwill
+1  A: 

If there are only a few cases, you can simple use render:

template = UserTemplate.find(<find criteria>)
render :inline => template.text

(Assuming that UserTemplate is the class modeling the templates)

Note, however, that I would primarily use database templates for dynamically modified templates. There are certainly uses for it -- at Rhiza we allow for customers to modify their welcome section dynamically, which would require a dynamic template.

Kathy Van Stone
AR! Right that's a good reminder, if there is no better alternatives, your answer make sense.
goodwill