Using Insert statement in active record?

A

Anukul Singhal

Hi,

I know this would be a simple solution to provide for any one of you. I
am new to active record and this is what I have currently done:

require 'rubygems'
require 'active_record'

puts "connecting to db...."

ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
# :username => "myuser",
:password => "schumi58",
:database => "test"
)

puts "connection established"

ActiveRecord::Schema.define do

drop_table:)testTable)

create_table:)testTable) do |t|
t.column :name, :string
end
end

I am also referring to Active Record's rdoc but am not able to make out
how to use the insert statement in the above code. Can anyone help me in
using INSERT statement in my code above?

Thanks,
Anukul
 
R

Roger Pack

Anukul said:
I am also referring to Active Record's rdoc but am not able to make out
how to use the insert statement in the above code. Can anyone help me in
using INSERT statement in my code above?

Thanks,
Anukul

Maybe post to the rails group?
=R
 
M

Martin Boese

Try:

class TestTable < ActiveRecord::Base
set_table_name 'testTable'
end

TestTable.new:)name=>'stuff').save
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top