Here is the code to make manual connection with database
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:username => "root",
:password => "abcd",
:database => "funonrails"
)
Load database configurations from yml file
dbconfig = YAML::load(File.open('database.yml'))
ActiveRecord::Base.establish_connection( dbconfig )
getting for the code above uninitialized constant YAML (NameError)what should i do?help me out
This is because YAML libray is not installed or not in path.Add library to your code before that ensure it exists.require "yaml"dbconfig = YAML::load(File.open('database.yml'))ActiveRecord::Base.establish_connection( dbconfig )