My controller (app/controllers/comments_controller.rb):
class CommentsController < ApplicationController
caches_page :index, :list, :show, :rss
[snip...]
def rss
@headers["Content-Type"] = "text/xml; charset=utf-8"
@comments = Comment.find_all nil, "date DESC", 20
end
end
My view (app/controllers/comments_controller.rb):
xml.rss("version" => "2.0") do
xml.channel do
xml.title("What They Said: Recent comments")
xml.link("http://www.whattheysaid.net/comments/")
xml.description "Recent comments posted to What They Said"
xml.language "en-us"
xml.ttl "40"
for comment in @comments
xml.item do
xml.title(comment.body)
xml.description(comment.body)
xml.pubDate(comment.date)
xml.link(''http://www.whattheysaid.net/quotations/show/'' +
comment.quotation_id + '''')
end
end
end
end
The error:
Processing CommentsController#rss (for 127.0.0.1 at Tue Apr 26 16:52:55
GMT 2005)
Parameters: {"action"=>"rss",
"id"=>"nil",
"controller"=>"comments"}
Comment Load (0.000389) SELECT * FROM comments ORDER BY date DESC
LIMIT 20
Rendering comments/rss (200 OK)
Comment Columns (0.000374) SHOW FIELDS FROM comments
ActionView::TemplateError (cannot convert Fixnum into String) on line #1
of /comments/rss.rxml:
1: xml.rss("version" => "2.0") do
2: xml.channel do
3: xml.title("What They Said: Recent comments")
4: xml.link("http://www.whattheysaid.net/comments/")
/gems/actionpack-1.8.1/lib/action_view/base.rb:278:in `+''
/gems/actionpack-1.8.1/lib/action_view/base.rb:278:in
`evaluate_locals''
/gems/actionpack-1.8.1/lib/action_view/base.rb:274:in `call''
/gems/actionpack-1.8.1/lib/action_view/vendor/builder/xmlbase.rb:138:in
`_nested_structures''
/gems/actionpack-1.8.1/lib/action_view/vendor/builder/xmlbase.rb:60:in
`method_missing''
/gems/actionpack-1.8.1/lib/action_view/base.rb:274:in
`evaluate_locals''
/gems/actionpack-1.8.1/lib/action_view/base.rb:273:in `each''
/gems/actionpack-1.8.1/lib/action_view/base.rb:273:in
`evaluate_locals''
/gems/actionpack-1.8.1/lib/action_view/base.rb:266:in `call''
/gems/actionpack-1.8.1/lib/action_view/vendor/builder/xmlbase.rb:138:in
`_nested_structures''
/gems/actionpack-1.8.1/lib/action_view/vendor/builder/xmlbase.rb:60:in
`method_missing''
/gems/actionpack-1.8.1/lib/action_view/base.rb:266:in
`evaluate_locals''
/gems/actionpack-1.8.1/lib/action_view/base.rb:265:in `call''
/gems/actionpack-1.8.1/lib/action_view/vendor/builder/xmlbase.rb:138:in
`_nested_structures''
/gems/actionpack-1.8.1/lib/action_view/vendor/builder/xmlbase.rb:60:in
`method_missing''
/gems/actionpack-1.8.1/lib/action_view/base.rb:265:in
`evaluate_locals''
/gems/actionpack-1.8.1/lib/action_view/base.rb:265:in
`evaluate_locals''
/gems/actionpack-1.8.1/lib/action_view/base.rb:283:in `rxml_render''
/gems/actionpack-1.8.1/lib/action_view/base.rb:201:in `send''
/gems/actionpack-1.8.1/lib/action_view/base.rb:201:in
`render_template''
/gems/actionpack-1.8.1/lib/action_view/base.rb:181:in `render_file''
/gems/actionpack-1.8.1/lib/action_controller/base.rb:458:in
`render_file''
/gems/actionpack-1.8.1/lib/action_controller/base.rb:440:in
`render_without_layout''
/gems/actionpack-1.8.1/lib/action_controller/layout.rb:211:in
`render_without_benchmark''
/gems/actionpack-1.8.1/lib/action_controller/benchmarking.rb:23:in
`render''
/gems/actionpack-1.8.1/lib/action_controller/benchmarking.rb:23:in
`measure''
/gems/actionpack-1.8.1/lib/action_controller/benchmarking.rb:23:in
`render''
/gems/actionpack-1.8.1/lib/action_controller/base.rb:709:in
`perform_action_without_filters''
/gems/actionpack-1.8.1/lib/action_controller/filters.rb:294:in
`perform_action_without_benchmark''
/gems/actionpack-1.8.1/lib/action_controller/benchmarking.rb:37:in
`perform_action_without_rescue''
/gems/actionpack-1.8.1/lib/action_controller/benchmarking.rb:37:in
`measure''
/gems/actionpack-1.8.1/lib/action_controller/benchmarking.rb:37:in
`perform_action_without_rescue''
/gems/actionpack-1.8.1/lib/action_controller/rescue.rb:79:in
`perform_action''
/gems/actionpack-1.8.1/lib/action_controller/base.rb:330:in `send''
/gems/actionpack-1.8.1/lib/action_controller/base.rb:330:in
`process''
/gems/actionpack-1.8.1/lib/action_controller/base.rb:273:in
`process''
/gems/rails-0.12.1/lib/dispatcher.rb:32:in `dispatch''
/var/www/whattheysaid/public/dispatch.fcgi:20
/var/www/whattheysaid/public/dispatch.fcgi:18:in `each_cgi''
/usr/lib/ruby/site_ruby/1.8/fcgi.rb:597:in `each''
/usr/lib/ruby/site_ruby/1.8/fcgi.rb:597:in `each_cgi''
/var/www/whattheysaid/public/dispatch.fcgi:18
Any ideas? This is almost identical to the example on the main page of
http://ap.rubyonrails.com/ (line #1 is exactly identical), so I''m at a
bit of a loss.
Thanks,
Myles