[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

how to acces a MySQL table with ActiveRecord

Pepe Sanchez

7/15/2006 6:23:00 PM

# require AR
require 'rubygems'
require_gem 'activerecord'

ActiveRecord::Base.establish_connection({
:adapter => "mysql",
:database => "cocoa",
:socket => "/tmp/mysql.socket",
:username => <myusername>,
:password => <mypassword>
})

# define a simple model
class Task < ActiveRecord::Base
end

I am trying to run this script in ruby that reads a MySQL table, called
Tasks, like in this example:

http://wiki.rubyonrails.com/rails/pages/HowToUseActiveRecordOu...

I got the following error message:
irb(main):001:0> Task.create "title" => "Item #1"
NameError: uninitialized constant Task
from (irb):1

--
Posted via http://www.ruby-....

1 Answer

Pepe Sanchez

7/16/2006 3:10:00 PM

0

here is the solution:
http://vsbabu.org/mt/archives/2005/07/19/oracle_with_active_r...


Jose Pepe wrote:
> # require AR
> require 'rubygems'
> require_gem 'activerecord'
>
> ActiveRecord::Base.establish_connection({
> :adapter => "mysql",
> :database => "cocoa",
> :socket => "/tmp/mysql.socket",
> :username => <myusername>,
> :password => <mypassword>
> })
>
> # define a simple model
> class Task < ActiveRecord::Base
> end
>
> I am trying to run this script in ruby that reads a MySQL table, called
> Tasks, like in this example:
>
> http://wiki.rubyonrails.com/rails/pages/HowToUseActiveRecordOu...
>
> I got the following error message:
> irb(main):001:0> Task.create "title" => "Item #1"
> NameError: uninitialized constant Task
> from (irb):1


--
Posted via http://www.ruby-....