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?
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?
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