I have activerecord-sybase-adapter installed -- and Sybase itself, so I
have the drivers.
In irb or in the rails console, this works:
ActiveRecord::Base.establish_connection(
:adapter => “sybase”,
:database => “mydb”,
:host => “myhost”,
:myport => myport,
:username => “read_only”,
:password => “read_only”)
In Rails, I have this in my database.yml:
pacs:
adapter: sybase
database: mydb
username: read_only
password: read_only
host: myhost
port: myport
And then I have the following model:
class PacsPatient < ActiveRecord::Base
establish_connection "pacs"
set_table_name "patient"
set_primary_key "pat_ckey"
end
So, when I go to the console and try to do something
like..>> PacsPatient.find 1
#<Class:0x481a610>: connect failed
from c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/sybct.rb:27:in
`connect''
from c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/sybct.rb:27:in
`open''
from c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/sybsql.rb:269:in
`initialize''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-sybase-adapter-1.0.0.9250/lib/active_record/connection_adapters/sybase_adapter.rb:46:in
`new''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-sybase-adapter-1.0.0.9250/lib/active_record/connection_adapters/sybase_adapter.rb:46:in
`sybase_connection''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in
`send''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in
`new_connection''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in
`checkout_new_connection''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in
`checkout''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in
`loop''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in
`checkout''
from c:/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in
`checkout''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in
`connection''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in
`retrieve_connection''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in
`retrieve_connection''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in
`connection''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:3103:in
`quoted_table_name''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1583:in
`find_one''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1574:in
`find_from_ids''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:616:in
`find''
from (irb):1>>
So it seems that I''m doing something wrong.. But what?
--
Posted via http://www.ruby-forum.com/.