Search code examples
ruby-on-railsrubydbfmigratedbase

How to migrate dbase database in rails


How to use rake with https://github.com/infused/dbf/. I tried to write in database.yml such text:

development:  
  adapter: dbf
  database: db/file.dbf
  pool: 5
  timeout: 5000

But it say, that didn't find adapter activerecord-dbf-adapter.
I need only read dbf-files.
PS. I can't use JDBC adapter.

UPDATE
I want to use dbf database such as another dabases (e.g. mysql) in rails with support ActiveRecord


Solution

  • I think you want to use dbf with ActiveRecord, but that it's not what this gem does. It just provides the ability to read dbf files from Ruby.

    To use it in your application you could write a class that would implement all the common methods you want and inherit from there, something like:

    require 'dbf'
    class DbfModel
    
      def initialize
        @table= DBF::Table.new("#{self.class.name}.dbf")
      end
    
      def find your_params_here
        @table.find your_params_here
      end
    
    end
    

    If do you want to use dbf with ActiveRecord you should find some adapter for it, but I haven't been lucky looking for it.