Indicate table name in ActiveRecord : Table Name « ActiveRecord « Ruby






Indicate table name in ActiveRecord



=begin

create database Contact;

use Contact;

CREATE TABLE Employee (
   Name VARCHAR(50),
   Phone VARCHAR(15)
);

=end

require "rubygems"
require "activerecord"

ActiveRecord::Base.establish_connection(
  :adapter => "mysql",
  :host => "localhost",
  :username => "root",
  :database => "Contact")

class Employee < ActiveRecord::Base
   set_table_name "employee"
end

account = Employee.new
account.Name = "AAA"
account.save

 








Related examples in the same category

1.Connection string for Oracle
2.PostgreSQL Connection Parameters
3.SQLite Parameters
4.SQL Server Parameters
5.Sybase Parameters