# Can you put layout rhtml into a database blob

**URL:** <https://www.ruby-forum.com/t/can-you-put-layout-rhtml-into-a-database-blob/109234>\
**Category:** Rails\
**Created:** [July 12, 2007, 4:34pm UTC](https://www.ruby-forum.com/t/can-you-put-layout-rhtml-into-a-database-blob/109234 "2007-07-12T16:34:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://www.ruby-forum.com/u/ian)\
**Post date:** [July 12, 2007, 4:34pm UTC](https://www.ruby-forum.com/t/can-you-put-layout-rhtml-into-a-database-blob/109234/1 "2007-07-12T16:34:27Z")

</div>

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.

e.g.

class WeblogController \< ActionController::Base  
layout :get\_template

def get\_template  
@attachment = current\_project.layout  
send\_data(@attachment.get\_data(current\_project),  
:filename =\> @attachment.name,  
:type =\> @attachment.content\_type,  
:disposition =\> ‘attachment’)  
end

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?

---

<div class="post-metadata">

**Author:** ![ian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://www.ruby-forum.com/u/ian)\
**Post date:** [July 12, 2007, 9:13pm UTC](https://www.ruby-forum.com/t/can-you-put-layout-rhtml-into-a-database-blob/109234/2 "2007-07-12T21:13:09Z")

</div>

ian wrote:

> def get\_template  
> any ideas?  
> The layout needs to be a file on disk cf. the source of  
> ActionController::Base.

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

–  
Cheers,

- Jacob A.

---

<div class="post-metadata">

**Author:** ![ian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://www.ruby-forum.com/u/ian)\
**Post date:** [July 12, 2007, 9:21pm UTC](https://www.ruby-forum.com/t/can-you-put-layout-rhtml-into-a-database-blob/109234/3 "2007-07-12T21:21:10Z")

</div>

Hi,

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.
