Dynamic layouts from DB

Hello,

I’m trying to get layouts from the database and use it as layout, but
its not working as excepted, it always try to find something from the
layout director

views/layouts/ ___ .rhtml

Even the below code render it as HTML and not ruby code

@layout = Layout.find(:first)
@test = “test”
render :text = @layout.html

Result:

joiasd jioasd ijoaidsoj ajiod <%= @test %>

I hope someone can point me in some direction, and thanks for your help
:slight_smile:

nothing :frowning: ?

The only solution I could think of is…

def index
@test = “adw”
render_layout(1)
end

private
def render_layout(id)
render :inline => Page.find_by_id(id).layout.html
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs