I have a Model that looks like this:
class Rounds << ActiveRecord::Base
... usual stuf ...
def played_rounds
Round.count(:conditions => ["contest_id = ?", self.id])
end
list_columns do |b|
... other fields here ...
b.static_text :played_rounds
end
end
This fails with the following STACK dump:
RuntimeError in Auto_admin#list
[The stack dump is several hundreds of KB's, looks like a recursion error]
Extracted source (around line #49):
46: <% end %>
47:
48: <%
49: admin_table( :model => model ) do |builder|
50: builder.outer do
51: builder.prologue do
52: model.list_columns.build builder
RAILS_ROOT: /Users/andy/DEV/Rails/xs_beldienst/config/..
Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/vendor/plugins/auto-admin/lib/auto_admin_django_theme.rb:106:in `table_cell'
#{RAILS_ROOT}/vendor/plugins/auto-admin/lib/auto_admin_simple_theme.rb:60:in `wrap_field'
#{RAILS_ROOT}/vendor/plugins/auto-admin/lib/auto_admin_simple_theme.rb:483:in `static_text'
#{RAILS_ROOT}/vendor/plugins/auto-admin/lib/declarative_form_builder.rb:26:in `method_missing'
#{RAILS_ROOT}/app/models/contest.rb:34
/usr/local/bin/mongrel_rails:18
I use the following workaround which does what I want, but is far from optimal of course :)
list_columns do |b|
b.html do |x|
x ? "<td>#{x.played_rounds}</td>" : "<th>Played rounds</th>"
end
end
Any ideas?