I have a rakefile.rb in which there is task called add_latest_apps
. This task creates some tables in a database if they have not been create using datamapper, scrapes some info from an xml feed and then puts the data in the tables. The problem is that I can't seem to get my rake task to run.
If I use the following command heroku run rake add_latest_apps
then I get: rake aborted! no such file to load -- dm-sqlite-adapter
which suggests to me that is trying to use the sqlite adapter even though it should be using the postgres adapter. What am I doing wrong?
rakefile.rb:
require 'open-uri'
require 'nokogiri'
require 'awesome_print'
require 'data_mapper'
require 'dm-postgres-adapter'
require 'pg'
task :add_latest_apps do
DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/app.db")
class Company
include DataMapper::Resource
property :id, Serial
property :company_name, String
property :company_id, Text, :unique => true
has n, :apps
end
class App
include DataMapper::Resource
property :id, Serial
property :app_id, Integer
property :bundle_id, Text
property :app_name, Text
property :company_name, Text
property :created_at, DateTime
property :rank, Integer
belongs_to :company
end
DataMapper.finalize.auto_upgrade!
puts 'Database and tables created'
#Get App data from Apple
#Insert apps and companies into database
end
Gemfile:
source :rubygems
gem 'sinatra', '1.1.0'
gem 'thin'
gem 'nokogiri'
gem 'awesome_print'
gem 'data_mapper'
gem 'dm-postgres-adapter'
gem 'pg'
Please help!