Forum: Ruby on Rails Can you put layout rhtml into a database blob

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
ian (Guest)
on 2007-07-12 18:34
(Received via mailing list)
Is there a way to move the layout .rhtml into a database blob?

I would like to get the information from the database and pass that to
the ActiveRecord layout and then have it pull the rest as normal.


 class WeblogController < ActionController::Base
    layout :get_template

def get_template
    @attachment = current_project.layout
              :filename =>,
              :type => @attachment.content_type,
              :disposition => 'attachment')

so that the layout can be passed from the database (or maybe not even
as an attachment just as a long text field).

any ideas?
Jacob A. (Guest)
on 2007-07-12 23:13
(Received via mailing list)
ian wrote:
> def get_template
> any ideas?
The layout needs to be a file on disk cf. the source of

What you can do is either: Write the layout to disk before calling
render or create your own layout system and use render :text.

- Jacob A.
ian (Guest)
on 2007-07-12 23:21
(Received via mailing list)

Layouts might be a bit much, I was looking for something like a
blogger template that you can insert partial files in given places.

This way you could add a banner, table of contents, comments, footer,
etc in the template and have this render like a layout and pull in
partials and page variables as needed.
This topic is locked and can not be replied to.