To get connected you database from your ruby file just include the "ActiveRecord" inside your ruby file.
require 'rubygems'
require 'activerecord'
 
#establish the connection.
  ActiveRecord::Base.establish_connection(
  :adapter => "mysql",
  :database => "database",
  :username => "username",
  :password => "password",
  :host => "localhost"
  )
 
  #create a class inherit with you activerecord base class.
  class User < ActiveRecord::Base
  end
 user = User.find(:first)
 puts user
  Or
  class SomeThing < ActiveRecord::Base
     set_table_name :users
  end
 user = SomeThing.find(:first)
  puts user
That's It.
Monday, September 28, 2009
Subscribe to:
Post Comments (Atom)
 

 
 Posts
Posts
 
 
1 comment:
can we see that the activerecord module contains what and which format plz
Post a Comment