开发者

Weird error with rails atom builder

开发者 https://www.devze.com 2023-03-10 11:02 出处:网络
I am trying to create a simple atom feed with the respond_to method in rails I have the respond to and routes set up properly but my builder errors. I have tried everything I can think of so hopefull

I am trying to create a simple atom feed with the respond_to method in rails

I have the respond to and routes set up properly but my builder errors. I have tried everything I can think of so hopefully StackOverflow can tell me what I overlooked

The error that atom builder is giving me is

undefined method `post_url' for #<#<Clas开发者_运维百科s:0x00000101c8f3a0>:0x00000101c8d460>

My builder code is pretty simple

atom_feed :language => "en-US" do |feed|
  feed.title SETTINGS[:organization_name]
  feed.updated @posts.first.created_at

  @posts.each do |post|
    feed.entry post do |entry| # this is the loop that causes the error
      feed.title post.name
      feed.content post.contents
      feed.url "/#{post.permalink}"
    end
  end
end

As you can see I isolated the loop that causes the error but without that loop I cannot add entries to the atom feed.


Shouldn't it be:

entry.title post.name
entry.content post.contents
entry.url "/#{post.permalink}"

I have no idea if this is a typo or if this is the problem you are experiencing. That being said, could you post more of your stacktrace?

0

精彩评论

暂无评论...
验证码 换一张
取 消