Rss Oluşturumu 11/08/07
Controller dosyamız:
# sondan başa son yazılar
def index
@liste = Giris.find(:all, :order => "updated_at, created_at" , :limit => 15, :conditions => 'ozel = false AND aktif = true')
@headers["Content-Type" ] = "application/rss+xml"
end
def index
@liste = Giris.find(:all, :order => "updated_at, created_at" , :limit => 15, :conditions => 'ozel = false AND aktif = true')
@headers["Content-Type" ] = "application/rss+xml"
end
index.rxml dosyamız
xml.instruct!
xml.rss "version" => "2.0" , "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
xml.channel do
xml.title 'SAYFA BAŞLIĞI'
xml.link url_for(:only_path => false, :controller => 'gunluk', :action => 'index' )
xml.pubDate CGI.rfc1123_date(@liste.first.updated_at)
xml.description h("AÇIKLAMA" )
@liste.each do |kayit|
xml.item do
xml.title kayit.baslik
xml.link url_for(:only_path => false,
:controller => 'gunluk' ,
:action => 'yazi' ,
:id => kayit.kisa_baslik)
xml.description kayit.kisa_icerik
xml.pubDate CGI.rfc1123_date(kayit.updated_at)
xml.guid url_for(:only_path => false,
:controller => 'gunluk' ,
:action => 'yazi' ,
:id => kayit.kisa_baslik)
xml.author "YAZAN"
end
end
end
end
xml.rss "version" => "2.0" , "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
xml.channel do
xml.title 'SAYFA BAŞLIĞI'
xml.link url_for(:only_path => false, :controller => 'gunluk', :action => 'index' )
xml.pubDate CGI.rfc1123_date(@liste.first.updated_at)
xml.description h("AÇIKLAMA" )
@liste.each do |kayit|
xml.item do
xml.title kayit.baslik
xml.link url_for(:only_path => false,
:controller => 'gunluk' ,
:action => 'yazi' ,
:id => kayit.kisa_baslik)
xml.description kayit.kisa_icerik
xml.pubDate CGI.rfc1123_date(kayit.updated_at)
xml.guid url_for(:only_path => false,
:controller => 'gunluk' ,
:action => 'yazi' ,
:id => kayit.kisa_baslik)
xml.author "YAZAN"
end
end
end
end
XmlBuilder sınıfından faydalandık.
yedek: hızlı rails ortamı (ortam.rb) 14/06/07
#!/usr/bin/ruby
# komut verir
def komut(islem, k)
puts "[Başlatılıyor] #{k}"
system(islem) ? puts("[Başlatıldı] #{k}") : puts("[Hata] #{k} - Hata Kodu: #{$?}")
end
# ortam için komutlar
komut('service mysql-server start', 'mysql')
komut('gem_server &', 'gem_server')
# komut verir
def komut(islem, k)
puts "[Başlatılıyor] #{k}"
system(islem) ? puts("[Başlatıldı] #{k}") : puts("[Hata] #{k} - Hata Kodu: #{$?}")
end
# ortam için komutlar
komut('service mysql-server start', 'mysql')
komut('gem_server &', 'gem_server')






