I get this xml error in view:
XML parse error: no element found
Location: http://localhost:3000/feed
Line 1, column 2:
My route.rb
match '/feed' => 'konkurrancers#feed',
:as => :feed,
:defaults => { :format => 'xml' }
My controller:
def feed
@posts = Konkurrancer.all(:select => "name, tracking, id, created_at", :order => "created_at DESC", :limit => 20)
respond_to do |format|
format.html
format.rss { render :layout => false } #index.rss.builder
end
My index.rss.builder:
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.channel do
xml.title "Your Blog Title"
xml.description "A blog about software and chocolate"
for konkurrancer in @posts
xml.item do
xml.title konkurrancer.name
xml.pubDate konkurrancer.posted_at.to_s(:rfc822)
xml.link konkurrancer.tracking
xml.guid konkurrancer.tracking
end
end
end
end
end
it's not xml
, it's rss
:
match '/feed' => 'konkurrancers#feed',
:as => :feed,
:defaults => { :format => 'rss' }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.