tks
tks

Reputation: 753

Setting entry id with Rails' atom_feed helper

I am using the atom feed builder method in Rails 3.2.2 to create a custom atom feed for a model's index method. I need to set the feed entry ids to a custom url. Currently the builder looks like this:

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

How can I set the id for the feed entry item? Doing something like

entry.id "foo"

does not work because it creates a duplicate id node rather than overwrite the default one. Like wise putting it as a part of feed.entry parameter, like I do with the configuration hash passed to atom_feed does not work because it is a syntax error.

Upvotes: 0

Views: 515

Answers (1)

tks
tks

Reputation: 753

I figured it out, the syntax is:

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

Upvotes: 4

Related Questions