Hello,
Can someone provide an example of using Builder to create multiple XML files from a SQL database. I can easily create one containing the entire database as in here...
def index
respond_to do |format|
format.xml { @rides = Rides.find(:all) }
end
end
This will create a file called index.xml based on a file I created called index.xml.builder which contains the following code
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
Here are the only lines in my routes.rb
map.resources :rides
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
This works fine, but how would I create a new file that contains the last element in Rides?
Thanks
edit: changed from format.rss to format.xml