<?xml version="1.0" encoding="UTF-8"?>
<posts type="array">
  <post>
    <comments-count type="integer">0</comments-count>
    <content>*&#1058;&#1091;&#1090; &#1074;&#1089;&#1077; &#1079;&#1072;&#1090;&#1086;&#1095;&#1077;&#1085;&#1086; &#1087;&#1086;&#1076; &#1084;&#1086;&#1080; &#1085;&#1091;&#1078;&#1076;&#1099;.*

&#1042;&#1086;&#1090; &#1088;&#1077;&#1096;&#1080;&#1083;&#1089;&#1103; &#1090;&#1072;&#1082;&#1080; &#1074;&#1090;&#1086;&#1088;&#1080;&#1095;&#1085;&#1086; &#1091;&#1081;&#1090;&#1080; &#1089; blogger. &#1053;&#1091; &#1074;&#1086;&#1090; &#1085;&#1077; &#1085;&#1088;&#1072;&#1074;&#1080;&#1090;&#1100;&#1089;&#1103; &#1084;&#1085;&#1077; &#1085;&#1072; &#1085;&#1077;&#1084; &#1074;&#1077;&#1089;&#1090;&#1080; &#1090;&#1077;&#1093;&#1085;&#1080;&#1095;&#1077;&#1089;&#1082;&#1080;&#1081; &#1073;&#1083;&#1086;&#1075; &#1089; &#1073;&#1086;&#1083;&#1100;&#1096;&#1080;&#1084; &#1082;&#1086;&#1083;&#1080;&#1095;&#1077;&#1089;&#1090;&#1074;&#1086;&#1084; &#1082;&#1086;&#1076;&#1072; &#1080; &#1080;&#1079;&#1086;&#1073;&#1088;&#1072;&#1078;&#1077;&#1085;&#1080;&#1081;.

&#1047;&#1072;&#1074;&#1077;&#1083; &#1076;&#1086;&#1084;&#1077;&#1085; &#1048;&#1084;&#1077;&#1085;&#1080;&#1052;&#1077;&#1085;&#1103;. &#1069;&#1090;&#1086; &#1076;&#1072;&#1078;&#1077; &#1085;&#1077; &#1073;&#1083;&#1086;&#1075;, &#1072; &#1087;&#1088;&#1086;&#1089;&#1090;&#1086; &#1087;&#1086;&#1090;&#1086;&#1082; &#1089;&#1086;&#1079;&#1085;&#1072;&#1085;&#1080;&#1103; &#1080; &#1079;&#1072;&#1087;&#1080;&#1089;&#1085;&#1072;&#1103; &#1082;&#1085;&#1080;&#1078;&#1082;&#1072; &#1086;&#1076;&#1085;&#1086;&#1074;&#1088;&#1077;&#1084;&#1077;&#1085;&#1085;&#1086;.

</content>
    <created-at type="datetime">2009-07-01T11:37:49+03:00</created-at>
    <delta type="boolean">false</delta>
    <id type="integer">1</id>
    <is-locked type="integer">2</is-locked>
    <published type="boolean">true</published>
    <updated-at type="datetime">2009-07-02T19:32:33+03:00</updated-at>
    <user-id type="integer">1</user-id>
  </post>
  <post>
    <comments-count type="integer">0</comments-count>
    <content>h3. DRY RSS Feed on Rails with inherited_resources &amp; responders

event.rb

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;

class Event &lt; ActiveRecord::Base
  default_scope :order =&gt; :&quot;created_at desc&quot;, :conditions =&gt; {:published =&gt; true}
  
  def self.per_page 
    10
  end
end
&lt;/code&gt;&lt;/pre&gt;

events_controller.rb

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
class EventsController &lt; ApplicationController
  inherit_resources
  
  respond_to :xml, :rss, :only =&gt; :index

  protected
  def collection
    @events = request.format.xml? ? end_of_association_chain.all : 
      end_of_association_chain.paginate(:per_page =&gt; resource_class.per_page,
        :page =&gt; params[:page])
  end
end
&lt;/code&gt;&lt;/pre&gt;

views/events.xml.builder

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
xml.rss :version =&gt; &quot;2.0&quot; do
  xml.channel do
    xml.title &quot;&#1053;&#1086;&#1074;&#1086;&#1089;&#1090;&#1080; &#1085;&#1072; example.com&quot;
    xml.description &quot;&#1057;&#1072;&#1084;&#1099;&#1077; &#1089;&#1074;&#1077;&#1078;&#1080;&#1077; &#1085;&#1086;&#1074;&#1086;&#1089;&#1090;&#1080; &#1085;&#1072; example.com&quot;
    xml.link collection_url
    xml.language('ru-ru')
    xml.lastBuildDate collection.first.created_at.to_s(:rfc822)
    xml.image do |logo|
      logo.title '&#1055;&#1086;&#1089;&#1083;&#1077;&#1076;&#1085;&#1080;&#1077; &#1085;&#1086;&#1074;&#1086;&#1089;&#1090;&#1080; example.com'
      logo.url url_for('images/logo.png')
      logo.link root_url      
    end

    collection.each do |resource|
      xml.item do
        xml.title resource.title
        xml.description do |description|
          description.cdata!(image_tag(resource.asset.url(:thumb), :align =&gt; :left, :hspace=&gt;10, :vspace=&gt;5) + resource.head.to_html)
        end
        xml.pubDate resource.created_at.to_s(:rfc822)
        xml.link resource_url(resource)        
      end
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

layouts/application.html.haml

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
%html
  %head
    = auto_discovery_link_tag :rss, events_url(:format =&gt; :xml)
&lt;/code&gt;&lt;/pre&gt;</content>
    <created-at type="datetime">2010-02-16T10:55:36+02:00</created-at>
    <delta type="boolean">true</delta>
    <id type="integer">67</id>
    <is-locked type="integer">0</is-locked>
    <published type="boolean">true</published>
    <updated-at type="datetime">2010-02-16T10:56:24+02:00</updated-at>
    <user-id type="integer">1</user-id>
  </post>
  <post>
    <comments-count type="integer">0</comments-count>
    <content>h2. &#1042; &#1043;&#1086;&#1085;&#1086;&#1083;&#1091;&#1083;&#1091; &#1085;&#1072; &#1082;&#1072;&#1103;&#1082;&#1077;

&quot;&#1054;&#1073;&#1088;&#1072;&#1090;&#1080;&#1090;&#1100; &#1074;&#1085;&#1080;&#1084;&#1072;&#1085;&#1080;&#1077; &#1085;&#1072; 8 &#1087;&#1091;&#1085;&#1082;&#1090;&quot;:http://maps.google.ru/maps?f=d&amp;source=s_d&amp;saddr=&#1057;&#1080;&#1101;&#1090;&#1083;,+&#1042;&#1072;&#1096;&#1080;&#1085;&#1075;&#1090;&#1086;&#1085;,+&#1057;&#1086;&#1077;&#1076;&#1080;&#1085;&#1105;&#1085;&#1085;&#1099;&#1077;+&#1064;&#1090;&#1072;&#1090;&#1099;+&#1040;&#1084;&#1077;&#1088;&#1080;&#1082;&#1080;&amp;daddr=&#1043;&#1086;&#1085;&#1086;&#1083;&#1091;&#1083;&#1091;&amp;hl=ru&amp;geocode=FcJp1gIdWVy1-ClVM-iTLBCQVDGa1URpRmUlEA;&amp;mra=ls&amp;sll=36.031332,-131.396484&amp;sspn=55.972814,114.169922&amp;ie=UTF8&amp;ll=27.44979,-111.796875&amp;spn=60.500607,114.169922&amp;z=4</content>
    <created-at type="datetime">2010-02-15T21:40:29+02:00</created-at>
    <delta type="boolean">true</delta>
    <id type="integer">66</id>
    <is-locked type="integer">0</is-locked>
    <published type="boolean">true</published>
    <updated-at type="datetime">2010-02-15T21:40:29+02:00</updated-at>
    <user-id type="integer">1</user-id>
  </post>
</posts>
