trying to use ActiveRecord with Sinatra, Migration fails question

Posted by David Lazar on Stack Overflow See other posts from Stack Overflow or by David Lazar
Published on 2010-05-31T00:20:44Z Indexed on 2010/05/31 0:22 UTC
Read the original article Hit count: 285

Filed under:
|

Hi, running Sinatra 1.0, I wanted to add a database table to my program. In my Rakefile I have a task

task :environment do   
    ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))["development"])      
end

I have a migration task in my namespace that calls the migration code:

    namespace :related_products do  
      desc "run any migrations we may have in db/migrate"
      task :migrate => :environment do   
        ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )   
    end 

My console pukes out an error when the call to ActiveRecord::MIgrator.migrate() is made. rake aborted! undefined method `info' for nil:NilClass

The migration code itself is pretty simple... and presents me with no clues as to what this missing info class is.

    class CreateStores < ActiveRecord::Migration
      def self.up       
        create_table :stores do |t|
          t.string :name
          t.string :access_url
          t.timestamps
        end
      end

      def self.down
        drop_table :stores
      end
    end  

I am a little mystified here and am looking for some clues as to what might be wrong. Thanks!

© Stack Overflow or respective owner

Related posts about activerecord

Related posts about sinatra