Dear all, Please help me in this regards, I am using models to access LegacySchemas using set_table_name and set_primary_key... [code for model] 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 [/code] and calling this in controllers like this, [code] class TestController < ApplicationController def view @cd_details = CdDetails.find_data end end [/code] 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:in `view'' How to solve this problem. -- with regds, Nahalingam N. Kanakavel. (http://www.nahalingam.bravehost.com/PlanetN/) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060722/a9048e72/attachment.html
"Nahalingam N. Kanakavel" <nahalingam@gmail.com> wrote in message news:f22d03ff0607220248h4e1b04dcndbe05b39781a8995@mail.gmail.com...> Dear all, > > Please help me in this regards, > > I am using models to access LegacySchemas using > set_table_name and set_primary_key... > > [code for model] > 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 > [/code] > > and calling this in controllers like this, > > [code] > class TestController < ApplicationController > def view > @cd_details = CdDetails.find_data > end > end > [/code] > > 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: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:in `establish_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:in `initialize'' 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:in `connection_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:in `retrieve_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 ---------- On 7/22/06, Alan Bullock <liststuff@gmail.com> wrote:> > "Nahalingam N. Kanakavel" > <nahalingam@gmail.com> wrote in message > news:f22d03ff0607220248h4e1b04dcndbe05b39781a8995@mail.gmail.com... > > Dear all, > > > > Please help me in this regards, > > > > I am using models to access LegacySchemas using > > set_table_name and set_primary_key... > > > > [code for model] > > 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 > > [/code] > > > > and calling this in controllers like this, > > > > [code] > > class TestController < ApplicationController > > def view > > @cd_details = CdDetails.find_data > > end > > end > > [/code] > > > > 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: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 > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- with regds, Nahalingam N. Kanakavel. (http://www.nahalingam.bravehost.com/PlanetN/) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060722/01f107ee/attachment.html
"Nahalingam N. Kanakavel" <nahalingam@gmail.com> wrote in message news:f22d03ff0607220405q60048499g8403486b038ad4be@mail.gmail.com...> 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:in > `establish_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:in `initialize'' > 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:in > `connection_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:in > `retrieve_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 > ----------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.