Created
January 7, 2010 09:20
-
-
Save hayeah/271105 to your computer and use it in GitHub Desktop.
Custom ActionController for Dress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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