Schema:
persons (id, name, birthyear, gender)
pets (id, person_id, name, leg_count)
plants (id, person_id, kind, qty)
I would like to make a read-only report about these things grouped by persons. The listing of personns is done (without the associated records). I would like to have "subtables" per persons. Something like:
Persons
+----+------+-----------+--------+
| id | name | birthyear | gender |
+----+------+-----------+--------+
| 1 | Joe | 1980 | M |
+----+------+-----------+--------+
| Pets |
| +----+------+-----------+ |
| | id | name | Leg count | |
| +----+------+-----------+ |
| | 1 | Rex | 4 | |
| +----+------+-----------+ |
| | 2 | Ka | 0 | |
| +----+------+-----------+ |
| Plants |
| +----+------------+-----+ |
| | id | kind | qty | |
| +----+------------+-----+ |
| | 1 | lemon tree | 2 | |
| +----+------------+-----+ |
+----+------+-----------+--------+
| 2 | Jane | 1982 | F |
+----+------+-----------+--------+
| Pets |
| +----+------+-----------+ |
| | id | name | Leg count | |
| +----+------+-----------+ |
| | 3 | Sue | 6 | |
| +----+------+-----------+ |
| Plants |
| +----+------------+-----+ |
| | id | kind | qty | |
| +----+------------+-----+ |
| | 2 | Oak tree | 1 | |
| +----+------------+-----+ |
+----+------+-----------+--------+
Can you please help me with some tips where and how to hook to the framework? (JRuby (1.5.0), Ruby on Rails (2.3.4), ActiveRecord (2.3.4) )
What is done
Persons
+----+------+-----------+--------+
| id | name | birthyear | gender |
+----+------+-----------+--------+
| 1 | Joe | 1980 | M |
+----+------+-----------+--------+
| 2 | Jane | 1982 | F |
+----+------+-----------+--------+
It is done using:
class PersonsReportController < PersonsController
layout 'simpreport'
active_scaffold :person do |config|
c.columns = [:name, :birthyear, :gender, :pets, :plants ]
c.label = "Report of people and other living creatures"
[:pets, :plants].each do |col|
columns[col].clear_link
end
c.list.columns.exclude :pets, :plants
c.actions.exclude :show
end
# ...
end
And I also customized _list_header.rhtml
, _list_column_headings.rhtml
, and _list_actions.rhtml
a little bit in order to kill all interactivity (like orderings and so on).