[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Using Insert statement in active record?

Anukul Singhal

7/19/2008 8:56:00 PM

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
--
Posted via http://www.ruby-....

2 Answers

Roger Pack

7/20/2008 12:10:00 AM

0

Anukul Singhal wrote:

>
> 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
--
Posted via http://www.ruby-....

Martin Boese

7/20/2008 11:17:00 AM

0

Try:

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

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


On Saturday 19 July 2008 21:55:53 Anukul Singhal wrote:
> 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