Rails 3帮助原子进给错误:未定义的方法`原子进给'

时间:2011-04-25 13:49:55

标签: ruby-on-rails ruby ruby-on-rails-3

我在浏览器中访问myapp / feed时出现此错误:

NoMethodError in Konkurrancers#feed

Showing C:/Rails/konkurranceportalen/app/views/konkurrancers/feed.atom.builder where line #1 raised:

undefined method `atom_feed' for #<#<Class:0x595dee0>:0x5956f08>

Extracted source (around line #1):

1: atom_feed :language => 'en-US' do |feed|
2:   feed.title @title
3:   feed.updated @updated

我的控制器:

def feed
  # this will be the name of the feed displayed on the feed reader
  @title = "Vindhimlen nye GRATIS konkurrencer"

  # the news items
  @news_items = Konkurrancer.order("updated_at desc")

  # this will be our Feed's update timestamp
  @updated = @news_items.first.updated_at unless @news_items.empty?

  respond_to do |format|
    format.atom { render :layout => false }

    # we want the RSS feed to redirect permanently to the ATOM feed
    format.rss { redirect_to feed_path(:format => :atom), :status => :moved_permanently }
  end
end

我的路线:

match '/feed' => 'konkurrancers#feed',
      :as => :feed,
      :defaults => { :format => 'atom' }

我的feed.atom.builder:

atom_feed :language => 'en-US' do |feed|
  feed.title @title
  feed.updated @updated

  @news_items.each do |item|
    next if item.updated_at.blank?

    feed.entry( item ) do |entry|
      entry.url news_item_url(item)
      entry.title item.title
      entry.content item.content, :type => 'html'

      # the strftime is needed to work with Google Reader.
      entry.updated(item.updated_at.strftime("%Y-%m-%dT%H:%M:%SZ")) 

      end
    end
  end

1 个答案:

答案 0 :(得分:0)

''是错误解释的控制字符。尝试将#coding: UTF-8添加为第一行(不要忘记)到feed.atom.builder