rails-postgresql

devise : new user registration issues , PG::ProtocolViolation . Rails4, Postgres

Deadly 提交于 2020-01-06 15:13:39
问题 I am using devise and omni-auth to login with linkedin . I added the from_omniauth method to user model as mentioned in the Railscast: This is the code: #Create a new user if does not exist def self.from_omniauth(auth) where(auth.slice(:provider, :uid)).first_or_create! do |user| user.provider = auth.provider user.uid = auth.uid user.email = auth.info.email end end Started GET "/users/auth/linkedin/callback?oauth_token=XXX" INFO -- omniauth: (linkedin) Callback phase initiated. Processing by

failing migrations : PG::ProtocolViolation Rails

本秂侑毒 提交于 2020-01-05 07:29:09
问题 I just updated to rails4 and realized that my db roles and database was somehow not setup. So I dropped the db and re-created the app_development db and the roles. Now I am trying to run rake db:migrate and its failing with following error: == DeviseCreateUsers: migrating ============================================== -- create_table(:users) -> 0.0081s -- add_index(:users, :email, {:unique=>true}) -> 0.0031s -- add_index(:users, :reset_password_token, {:unique=>true}) -> 0.0030s ==

postgresql 9.3 log slow queries

断了今生、忘了曾经 提交于 2020-01-02 05:29:12
问题 I am using Rails application with Postgres 9.3 database and doing some performance fixes. I would like to know how to find out slowest queries in log files. let say queries taking more then 30ms. 回答1: In postgresql.conf you should uncomment line #log_min_duration_statement = -1 and change its value to 30. This way queries longer than 30ms will be logged 来源: https://stackoverflow.com/questions/41746897/postgresql-9-3-log-slow-queries

rspec returns “PG::Error: ERROR: relation ”table_name“ does not exist”

血红的双手。 提交于 2019-12-31 21:42:34
问题 Environment is REE(2011.12) on rvm, rspec 2.8.0, rails 3.0.6, and pg 0.13.2. Using PostgreSQL 8.3.17 on CentOS 5.6. The db:migrate have work correctly. But rspec have got following error. 1) ApiController articles OK Failure/Error: Unable to find matching line from backtrace ActiveRecord::StatementInvalid: PG::Error: ERROR: relation "table_name" does not exist : DELETE FROM "table_name" I'm updating my project from rails 2.3.5 with rspec 1.x series to rails 3.0 with rspec2. Copied all rspec

Rake tasks seem to ignore database.yml configuration

孤街浪徒 提交于 2019-12-31 02:58:07
问题 I am using MAC OS X along with postgresql installed via Homebrew. I am developing using Rails 4.2.1 and ruby 2.2.0. The connection with postgresql server is fine but for some reason every application accesses the database "kstavrou" which is my system username, as a development database and creates the rest as defined by database.yml. That is troublesome if you have more than 1 rails app. rake db:create output: Konstantinoss-MacBook-Pro:ecomm-intel kstavrou$ rake db:create kstavrou already

Postgresql adapter (pg): could not connect to server

痞子三分冷 提交于 2019-12-28 04:51:05
问题 I get this error every this I run my Rails app (It cannot connect to my local Postgresql ) /Users/leonardo/.rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.11/lib/ active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize': could not connect to server: No such file or directory (PG::Error) Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? I'm using Postgres.app that it's correctly running. If I run $ psql I can

Why is Rails dropping the Postgres connection on large bulk inserts?

本小妞迷上赌 提交于 2019-12-24 14:34:52
问题 I'm brand-spanking new to the world of linux and server administration, and I'm stuck. I have a rails app that occasionally needs to perform large data inserts, usually around 20,000 rows. The code seems to work fine in development (osx), but on the production servers (ubunto, on a linode vps), it fails every time, usually after about 1,700 insertions. The precise number varies (1655, 1697, 1756), but it's consistently in that ballpark. I'm not seeing much that's helpful in the production.log

ERROR: function unnest(integer[]) does not exist in postgresql

ぃ、小莉子 提交于 2019-12-23 20:01:16
问题 SELECT UNNEST(ARRAY[1,2,3,4]) While executing the above query I got the error like this: ERROR: function unnest(integer[]) does not exist in postgresql. I am using PostgreSQL 8.3 and I have installed the _int.sql package in my db for integer array operation. How to resolve this error? 回答1: unnest() is not part of the module intarray , but of standard PostgreSQL. However, you need version 8.4 or later for that. So you can resolve this by upgrading to a more recent version, preferably the

Postgres accent insensitive LIKE search in Rails 3.1 on Heroku

北慕城南 提交于 2019-12-20 17:42:30
问题 How can I modify a where/like condition on a search query in Rails: find(:all, :conditions => ["lower(name) LIKE ?", "%#{search.downcase}%"]) so that the results are matched irrespective of accents? (eg métro = metro). Because I'm using utf8, I can't use "to_ascii". Production is running on Heroku. 回答1: Poor man's solution If you are able to create a function, you can use this one. I compiled the list starting here and added to it over time. It is pretty complete. You may even want to remove

rake db:create fails, authentication problem with postgresql 8.4

浪尽此生 提交于 2019-12-20 14:22:42
问题 first things first, please excuse my utter noobness. I really tried to find a solution out there, but now i'm stuck and completely clueless. i'm trying to deploy a rails 3 app on a distant server ; when developping on my local VM, no problem showed. But now, when i try to run rake db:create it fails, with error (here translated, since i'm french): FATAL : password authentication failed for user <<mylogin>> here's my database.yml : login: &login adapter: postgresql username: mylogin password: