views:

102

answers:

1

Hi

I want to use a custom template file which shoud use the base layout file (app/view/layouts/application.html.erb) in a Rails metal code. Can somebody give me some hints what I need to require or how I can do that?

+1  A: 
require 'erb'
class Poller # in metal
  def self.call(env)
    # can find abs path using File.dirname(__FILE__) / .. / app / ...
    view = IO.read(`/absolute/path/app/view/layouts/application.html.erb`)
    template = ERB.new(view)
    body = template.result(binding)
    [200, {"Content-Type" => "text/html"}, body]
  end
end
clyfe
thank you so much :)
xaver23