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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F0d09ef2a279cae4ac312164aa1af6d3?d=identicon&s=25 ian (Guest)
on 2007-07-12 16: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.

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?
Cb98c59a6ff22c72676e756bbd28f266?d=identicon&s=25 Jacob Atzen (Guest)
on 2007-07-12 21: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
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 Atzen
F0d09ef2a279cae4ac312164aa1af6d3?d=identicon&s=25 ian (Guest)
on 2007-07-12 21:21
(Received via mailing list)
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.
This topic is locked and can not be replied to.