Connection refused - connect(2)

Dear all,

Please help me in this regards,

I am using models to access LegacySchemas using
set_table_name and set_primary_key…

class CdDetails < ActiveRecord::Base
    def self.find_data
        set_table_name 'cd_details'
        set_primary_key 'cd_label'

        find (:first,
              :select => "cd_label")
    end
end

and calling this in controllers like this,

class TestController < ApplicationController
    def view
        @cd_details = CdDetails.find_data
    end
end

my database configuration is

adapter: postgresql
database: cdlibrary
username: cdlibrary
password: cdlibrary

If I call this action “VIEW” from test controller, I am getting the
following error message in screen,
Errno::ECONNREFUSED in TestController#view

Connection refused - connect(2)

#{RAILS_ROOT}/app/models/cd_details.rb:7:in find_data' #{RAILS_ROOT}/app/controllers/test_controller.rb:4:inview’

How to solve this problem.

“Nahalingam N. Kanakavel”
[email protected] wrote in message
news:[email protected]

   set_table_name 'cd_details'

[code]
database: cdlibrary
#{RAILS_ROOT}/app/controllers/test_controller.rb:4:in `view’

How to solve this problem.


with regds,
Nahalingam N. Kanakavel.
(http://www.nahalingam.bravehost.com/PlanetN/)

Hi

I’m not sure about your specific problem but have you checked that your
rails app is able to connect to the database? try this from
script/console:

ActiveRecord::Base.connection

if that doesn’t raise any exceptions then the connection’s OK

Hi,

I am sorry Alan, there also I am getting the same errors,
If so what could be the problem.

Output from console is given below.

Errno::ECONNREFUSED: Connection refused - connect(2)
from
/usr/local/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:138:in
initialize' from /usr/local/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:138:inestablish_connection’
from
/usr/local/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:25:in
initialize' from /usr/local/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0 /lib/postgres-pr/postgres-compat.rb:23:ininitialize’
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/connection_adapters/postgresql_adapter.rb:24:in
postgresql_connection' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:251:inconnection_without_query_cache=’
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/query_cache.rb:54:in
connection=' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:220:inretrieve_connection’
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in
`connection’
from (irb):1

“Nahalingam N. Kanakavel”
[email protected] wrote in message
news:[email protected]

initialize'postgresql_connection’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in
`connection’
from (irb):1

you have a problem with your connection somewhere. check that your
database.yml file has the correct settings and that your db server is
accepting connections from your development machine… other than that I
don’t know but I’m pretty sure it’s your db connection and not your
rails
code that’s causing the problem.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs