This is mostly the same as standard rails. Hobo does shorten the controller side if you don’t need any filtering.
In your controller, add an indexaction for your feed.
index_action :rss
Hobo index actions will paginate for html requests but by default do not for xml requests.
Then add the view file under /app/views/controller/rss.builder
xml.instruct! :xml, :version => "1.0"
xml.rss "version" => "2.0" do
xml.channel do
xml.title "news"
xml.link url_for(:only_path => false, :controller => 'posts')
xml.description "news items"
@posts.each do |post|
xml.item do
xml.title post.title
xml.link url_for(:only_path => false, :controller => 'posts', :action => 'show', :id => post.id)
xml.description post.body
xml.updated_at post.updated_at
xml.guid url_for(:only_path => false, :controller => 'posts', :action => 'show', :id => post.id)
end
end
end
end
The above is from a feed I created for a posts controller. Substitute your fields as needed.
On December 17, 2009 txinto said:
Thanks.
.......
NoMethodError in OffersController#index
undefined method `total_pages' for #<Array:0x1051a06e8>
...
Application Trace | Framework Trace | Full Trace
/Library/Ruby/Gems/1.8/gems/will_paginate-2.3.11/lib/will_paginate/view_helpers.rb:197:in `total_pages_for_collection'
/Library/Ruby/Gems/1.8/gems/will_paginate-2.3.11/lib/will_paginate/view_helpers.rb:98:in `will_paginate'
...