2012-04-30 20 views
0

我在Rails 3.2.2中使用atom feed builder方法爲模型的索引方法創建自定義原子提要。我需要將供稿條目ID設置爲自定義網址。目前該構建器如下所示:使用Rails的atom_feed helper設置條目ID

atom_feed ({:id => request.url}) do |feed| 
    feed.title "Title" 
    feed.author do |author| 
    author.name @user.name 
    end 
    feed.category("term" => "thing feed") 
    feed.updated @things.first.created_at if @things.any? 
    @things.each do |thing| 
    feed.entry (thing) do |entry| 
     [... setting the entry with some thing attributes] 
    end 
    end 
end 

如何設置供稿條目項目的ID?做類似

entry.id "foo" 

不起作用,因爲它創建了一個重複的id節點而不是覆蓋默認的節點。像明智地把它作爲feed.entry參數的一部分,就像我配置散列傳遞給atom_feed不行,因爲它是一個語法錯誤。

回答

2

我想通了,語法是:

feed.entry thing, {:id => custom_id} do |entry|