Subskrypcja Atom

Transkrypt

Subskrypcja Atom
Subskrypcja Atom
W art ykule pokaże jak w banalny sposób można dodać subskrypcje at om do aplikacji
rails-owej.
Do kotrolera którego chcemy subskrybować dodajemy:
#articles_controller.rb/index
respond_to do |format|
format.atom
# index.atom.builder
format.xml { render :xml => @articles }
end
Kolejnym etapem jest stworzenie pliku index.atom.builder a w nim:
#index.atom.builder
atom_feed do |feed|
feed.title "Mosinski Blog"
feed.updated @articles.first.created_at
@articles.each do |article|
feed.entry article do |entry|
entry.title article.title
entry.content article.body, :type => 'html'
entry.author do |author|
author.name "Miłosz Osiński"
end
end
end
end
Na koniec wystarczy dodać layout-u w znaczniku < head > wpisać:
#app/view/layouts/application.html.erb
<%= auto_discovery_link_tag(:atom, articles_path(:atom)) %>
Ostatnia modyfikacja 18:08 17-04-2013 przez Miłosz O siński
Kateg o ria: RUBY O N RAILS