Class: ARViewWidget

Inherits:
Cuca::Widget show all
Defined in:
lib/cuca/stdlib/arview.rb

Overview

ARViewWidget - Display an ActiveRecord record.

This is a small widget to quick&dirty display the content of a record.

Example

mab { ARView(User.find(:id=>123)) }

Instance Method Summary collapse

Methods inherited from Cuca::Widget

#app, #cgi, #clear, clear_hints, #content, #content=, #controller, define_attr_method, #escape, #escapeHTML, #get_assigns, #hints, #initialize, #log, #params, #query_parameters, #request_method, #request_parameters, run_attr_method, #session, #to_s, #unescape, #unescapeHTML

Constructor Details

This class inherits a constructor from Cuca::Widget

Instance Method Details

#output(model) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/cuca/stdlib/arview.rb', line 13

def output(model)
 @model = model

  r = "<table>"
  @model.class.columns.each do |col|
    r << "<tr><td>#{col.name}</td><td>#{@model.send(col.name.intern)}</td></tr>"
  end
  r << "</table>"
  @_content = r
end