Skip to content

Instantly share code, notes, and snippets.

@jystewart
Created August 9, 2009 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jystewart/164667 to your computer and use it in GitHub Desktop.
Save jystewart/164667 to your computer and use it in GitHub Desktop.
# to move data to drupal
require 'activerecord'
class ActiveRecord::Drupal < ActiveRecord::Base
self.abstract_class = true
establish_connection(
:adapter => "mysql",
:host => "localhost",
:username => "root",
:password => "",
:database => "nm_drupal"
)
end
class Vocabulary < ActiveRecord::Drupal
set_table_name 'vocabulary'
set_primary_key 'vid'
has_many :terms, :foreign_key => :vid
end
class Node < ActiveRecord::Drupal
set_table_name 'node'
set_primary_key 'nid'
end
class NodeRevision < ActiveRecord::Drupal
set_table_name 'node_revisions'
set_primary_key 'vid'
end
class TermNode < ActiveRecord::Drupal
set_table_name 'term_node'
end
class Term < ActiveRecord::Drupal
set_table_name 'term_data'
set_primary_key 'tid'
belongs_to :vocabulary, :foreign_key => :vid
end
class ContentTypeListing < ActiveRecord::Drupal
set_table_name 'content_type_listing'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment