From: cristian cristian Date: 2013-06-25T17:15:19+09:00 Subject: Re: Beginners problem with database and datamapper Ok, Now I have been trying to change the code so I can store the information in another DB-table. I have been searching for information but I know im doing something terrible wrong. I would like to store the dateTime and site.id (from table/class Site)into a table called Stats. I thought that this could be done within the "Site.all.each do..." but I get a lot of errors... Any suggestions how to continue? Br cristian This is the code so far: require 'rubygems' require 'mechanize' require 'data_mapper' #Sqlite3 connection DataMapper.setup(:default, 'sqlite:///Ruby/Stats/StatsDB.sqlite') class Site # I'd rename your Url class include DataMapper::Resource property :id, Serial property :description, String property :url, String # url in lowercase end class Stats include DataMapper::Resource property :id, Serial property :date, DateTime property :url_id, Integer end time=Time.now.strftime("%Y-%m-%d %H:%M") Site.all.each do |site| puts site.url Stats.create( :Date => time, :url_ID => site.id ) end -- Posted via http://www.ruby-forum.com/.