Builderを使用してSQLデータベースから複数のXMLファイルを作成する例を誰かが提供できますか?ここのようにデータベース全体を含むものを簡単に作成できます...
def index
respond_to do |format|
format.xml { @rides = Rides.find(:all) }
end
end
これにより、次のコードを含むindex.xml.builderという名前のファイルに基づいてindex.xmlというファイルが作成されます。
xml.instruct!
xml.rides do
@rides.each do |ride|
xml.item("togive" => ride.togive, "totake" => ride.totake, "howlong" => ride.howlong, "isoffer" => ride.isoffer, "id" => ride.id, "contact" => ride.contact)
end
end
これが私のroutes.rbの唯一の行です
map.resources :rides
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
これは正常に機能しますが、Ridesの最後の要素を含む新しいファイルを作成するにはどうすればよいですか?
ありがとう
編集:format.rssからformat.xmlに変更