rails-postgresql

PostgreSQL date() with timezone

喜你入骨 提交于 2019-12-20 08:39:56
问题 I'm having an issue selecting dates properly from Postgres - they are being stored in UTC, but not converting with the Date() function properly. Converting the timestamp to a date gives me the wrong date if it's past 4pm PST. 2012-06-21 should be 2012-06-20 in this case. The starts_at column datatype is timestamp without time zone . Here are my queries: Without converting to PST timezone: Select starts_at from schedules where id = 40; starts_at --------------------- 2012-06-21 01:00:00

How to set up Postgres database for local Rails project?

北城余情 提交于 2019-12-20 08:20:17
问题 I recently got a new machine and would now like to work on my projects from Github. I'm curious as to how to properly set up the Postgres database on my local machine. I have postgresql , pgadmin3 and libpq-dev installed on Ubuntu (12.04). I pull down the project: git clone https://github.com/thebenedict/cowsnhills.git and run: bundle . When I run: rake db:create && rake db:schema:load I get this error: rake db:create && rake db:schema:load FATAL: password authentication failed for user "cnh"

Rails: rake db:create:all (could not connect to server)

筅森魡賤 提交于 2019-12-19 09:24:37
问题 follow the screencasts http://railscasts.com/episodes/342-migrating-to-postgresql?autoplay=true up to the steps of "rake db:create:all" and get error: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? refer the question on Rails: rake db:create:all fails to connect to PostgreSQL database but still unable to resolve it. Not sure what is the problem. [database.yml] development: adapter:

Ruby on Rails+PostgreSQL: usage of custom sequences

淺唱寂寞╮ 提交于 2019-12-18 16:34:08
问题 Say I have a model called Transaction which has a :transaction_code attribute. I want that attribute to be automatically filled with a sequence number which may differ from id (e.g. Transaction with id=1 could have transaction_code=1000 ). I have tried to create a sequence on postgres and then making the default value for the transaction_code column the nextval of that sequence. The thing is, if I do not assign any value to @transaction.transaction_code on RoR, when I issue a @transaction

Heroku + Sidekiq: ActiveRecord::StatementInvalid: PG::UnableToSend: SSL SYSCALL error: EOF detected

跟風遠走 提交于 2019-12-18 14:13:04
问题 Hi we are running on Heroku's Cedar stack with Unicorn and Sidekiq. We intermittently get the following errors BurnThis ActiveRecord::StatementInvalid: PG::UnableToSend: SSL SYSCALL error: EOF detected ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() SSL SYSCALL error: Connection timed out Does anyone have any insight what the direct cause of these errors? Is it too many connections to our database? We have our forking set up already in the following way: unicorn.rb worker

Set default value for Postgres JSON column in Rails < 4

本秂侑毒 提交于 2019-12-18 12:58:06
问题 So I'm starting to use the Postgres JSON datatype, now that there's a lot of fun stuff you can do with it. In one of my Rails apps which is not yet Rails 4 (where support for Postgres JSON has been added) I added a JSON column like this: create_table :foo do |t| t.column :bar, :json end but I can't figure out how to set a default value for the column. I tried all variations like {} , '{}' , '{}'::json , '[]'::json etc. but I either get an error when the migration runs or it simply doesn't

Connection refused (PGError) (postgresql and rails)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 03:59:04
问题 I keep getting this error when i try to run my localhost using "$rails s": (Mac OSX 10.8.3) (ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]) (Rails 3.2.11) (psql (PostgreSQL) 9.2.2 ) **installed with homebrew I have been doing a lot of uninstalling postgresql and reinstalling so I have a hunch that there may be conflicting libraries somewhere...i just dont know where to start. I had Postgresql 9.1 and 9.2 in the same folder and just moved 9.1 into the trash. Here is the

Connection refused (PGError) (postgresql and rails)

浪子不回头ぞ 提交于 2019-12-18 03:58:56
问题 I keep getting this error when i try to run my localhost using "$rails s": (Mac OSX 10.8.3) (ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]) (Rails 3.2.11) (psql (PostgreSQL) 9.2.2 ) **installed with homebrew I have been doing a lot of uninstalling postgresql and reinstalling so I have a hunch that there may be conflicting libraries somewhere...i just dont know where to start. I had Postgresql 9.1 and 9.2 in the same folder and just moved 9.1 into the trash. Here is the

Error when creating unaccent extension on PostgreSQL

China☆狼群 提交于 2019-12-17 10:52:08
问题 I am trying to configure PostgreSQL to use fulltext search in my rails app as mentioned in this Railscast. I am using a fresh Ubuntu 12.04 server running PostgreSQL 9.1.5 installed using apt-get with the ppa:pitti/postgresql with precise . I get the following error when trying to run the migration and when I try the same command in the psql console with the peer postgres user: postgres=# CREATE EXTENSION unaccent; ERROR: could not open extension control file "/usr/share/postgresql/9.1

PG::ConnectionBad - could not connect to server: Connection refused

坚强是说给别人听的谎言 提交于 2019-12-17 00:24:29
问题 Every time I run my rails 4.0 server, I get this output. Started GET "/" for 127.0.0.1 at 2013-11-06 23:56:36 -0500 PG::ConnectionBad - could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running