Ruby 1.9.3-p392 and PostgreSQL

I created a new rails app with rails new app_name -d postgresql and I am failing to use any rails command (rails s, rails g controller ControllerName, etc etc). I am getting these errors:

/Users/sebkomianos/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in ``initialize': could not connect to server: No such file or directory (PG::Error)

This is my database.yml file:

development:
  adapter: postgresql
  encoding: unicode
  database: project_development
  pool: 5
  username: project
  password:`

test:
  adapter: postgresql
  encoding: unicode
  database: project_test
  pool: 5
  username: project
  password:`

production:
  adapter: postgresql
  encoding: unicode
  database: project_production
  pool: 5
  username: project
  password:`

I am having the exact same problem when I create the rails app with the standard rails new app_name command and manually change the Gemfile to use the pg gem.

A couple of weeks ago I was on ruby2 and the app I created was working fine. Rails version is 3.2.13.

Any ideas?

UPDATE: The funny (at least to me) thing is that I have the application deployed to heroku and it runs fine there. Now, if I run rake db:create everything seems to be working fine locally as well (no need to change anything in the database.yml file). Maybe that makes my problem more clear?

Answers


You may need to specify the socket argument in your config/database.yml to specify the full path to the Postgres UNIX-type socket if that's what you're using. It may be in a non-standard location.

I usually avoid checking config/database.yml into the project source repository as it causes conflicts with other people working on the same code-base that have different configurations. Include a database.yml.example as a helpful template to get started instead.

Adding host: localhost usually has the effect of forcing a TCP/IP connection instead, but this might not be working for you. Sometimes host: 127.0.0.1 works instead, as localhost might be interpreted as "use default UNIX socket".


Need Your Help

Finding right Android touchscreen driver file

android kernel driver touchscreen

My goal is to add a single printk command to one of the driver files for my phone's touchscreen. I would like to run this printk command everytime the screen recieves touch input. I found the list of

WCF Service Throttling settings for concurrency with SQL Transaction

asp.net wcf concurrency service transactions

I have a WCF service that has a complex operationcontract that has to executed atomically i.e. either the entire operation succeeds or fails. The WCF service is hosted on IIS server in an ASP .NET

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.