Created
January 7, 2011 18:14
-
-
Save joemsak/769856 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
respond_to :html, :rss | |
def index | |
@news_items = NewsItem.published.paginate(:page => params[:page], :per_page => NewsItem.per_page) | |
respond_with @news_items do |format| | |
format.html | |
format.rss { render :layout => false } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xml.instruct! :xml, :version => "1.0" | |
xml.rss :version => "2.0" do | |
xml.channel do | |
xml.title RefinerySetting.find_or_set(:site_name, "Neoteric Design") | |
xml.description RefinerySetting.find_or_set(:site_name, "Neoteric Design") + " News" | |
xml.link news_items_url | |
@news_items.each do |post| | |
xml.item do | |
xml.title post.title | |
xml.description post.body | |
xml.pubDate post.publish_date.to_s(:rfc822) | |
xml.link news_item_url(post) | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NoMethodError in News_items#index.rss | |
Showing /Users/.../views/news_items/index.rss.builder where line #8 raised: | |
You have a nil object when you didn't expect it! | |
You might have expected an instance of Array. | |
The error occurred while evaluating nil.each | |
Extracted source (around line #8): | |
6: xml.link news_items_url | |
7: | |
8: @news_items.each do |post| | |
9: xml.item do | |
10: xml.title post.title | |
11: xml.description post.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment