Skip to content

Instantly share code, notes, and snippets.

@hayeah
Created January 7, 2010 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hayeah/271105 to your computer and use it in GitHub Desktop.
Save hayeah/271105 to your computer and use it in GitHub Desktop.
Custom ActionController for Dress
require 'dress'
class Dresser < ActionController::Base
class Page < Dress::ActiveView
# TODO layout should render in the context of the page
layout do
html {
head {
meta("content" => "text/html; charset=UTF-8", "http-equiv" => "Content-Type")
title("VersaPay EFT Admin")
}
body {
n random_fortune
div.content { content }
}
}
end
def random_fortune
div {
`fortune`.split("\n").each { |l| div(l)}
}
end
# tabulate(["field1","field2"],hashes)
def tabulate(fields,records)
table {
tr {
fields.each { |f| th(f) }}
records.each do |record|
tr {
record.values_at(*fields).each { |v| td(v) }
}
end
}
end
end
def process_action(method,*args)
r = send(method)
self.response_body = r.to_s
end
def render(method,*args)
self.class::Page.new(self).render(method,*args)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment