2010-04-01 2 views
8

AtomFeedHelper를 사용하고 있습니다. 각 항목을 기본 polymorphic_url이 아닌 URL에 연결해야하는 경우를 제외하고는 모든 것이 올바르게 작동합니다. 그 기록.레일 AtomFeedBuilder 항목 : URL 옵션은 URL 태그에 있지만 링크 태그에는 표시되지 않습니다.

설명서에 따라 항목에 대해 : url 옵션을 지정했습니다. 이렇게하면 원자 노드에 <url> 태그가 올바르게 렌더링되지만 <link rel="alternate"은 여전히 ​​기본 polymorphic_url을 가리 킵니다. 출처와 문서를 보면 왜 이런 일이 일어나고 있는지 이해할 수 없습니다.

<entry> 
    <id>tag:myhost.mydomain.com,2005:SiteReport/2</id> 
    <published>2010-03-30T13:11:07-07:00</published> 
    <updated>2010-03-30T13:11:07-07:00</updated> 
    <link rel="alternate" type="text/html" href="http://myhost/site_reports/2"/> 
    <title>Test Title</title> 
    <content type="html">Test Content</content> 
    <url>http://myhost/page/</url> 
    <updated>2010-03-30T13:11:07Z</updated> 
    <author> 
     <name>Author</name> 
    </author> 
    </entry> 

내가 URL 태그의 값과 일치하도록 링크 태그의 HREF 값을 원하는 : 여기
atom_feed do |feed| 
    feed.title("Reports") 
    feed.updated(@reports.first.created_at) 
    for report in @reports 
    content = report.notes 

    feed.entry(report) do |entry| 
     entry.title(report.title) 
     entry.content(content, :type => 'html') 
     entry.url("http://myhost/page/") 
     entry.updated(report.updated_at.strftime("%Y-%m-%dT%H:%M:%SZ")) 
     entry.author do |author| 
     author.name(report.user.username) 
     end 
    end 
    end 

end 

문제 노드의 예 : 여기

는 예를 들어 빌더의 그러나 그렇지 않습니다.

여기 항목 http://api.rubyonrails.org/classes/ActionView/Helpers/AtomFeedHelper/AtomFeedBuilder.html

나는이 라인이 제대로 작동한다고 가정 것 나열된 소스를 볼 때 :

@xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:url] || @view.polymorphic_url(record)) 

혼란. 전에 만난 사람이 있습니까?

감사합니다. , 나는 "업데이트"와 "게시"태그를 변경하려면이 같은 방법을 사용할 수 있었다

feed.entry(report, :url => report_url(report.slug)) do |entry|

답변

18

이 난을 전달하여이 작업을 수행 각 항목에 대해서도.
+0

덕분에 다음 feed.entry 방법에 직접 URL 옵션 : – konyak