rails-postgresql

Rails pg gem Incompatible library version

為{幸葍}努か 提交于 2019-12-03 06:45:58
I'm getting the following 'incompatible library version' error when I try and access my Ruby on Rails website in development mode. incompatible library version - /var/www/vhosts/launch.site.com/httpdocs/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg_ext.so (LoadError) /var/www/vhosts/launch.site.com/httpdocs/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg.rb:4:in `require' /var/www/vhosts/launch.site.com/httpdocs/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg.rb:4:in `<top (required)>' /usr/local/rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require' /usr/local/rvm/gems

Postgres accent insensitive LIKE search in Rails 3.1 on Heroku

与世无争的帅哥 提交于 2019-12-03 05:15:17
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. Erwin Brandstetter 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 some characters: CREATE OR REPLACE FUNCTION lower_unaccent(text) RETURNS text AS $func$

rake db:create fails, authentication problem with postgresql 8.4

放肆的年华 提交于 2019-12-03 03:34:48
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: mypassword host: localhost port: 5432 encoding: UTF8 development: <<: *login database: somesite

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

杀马特。学长 韩版系。学妹 提交于 2019-12-03 03:34:06
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 tests, and I have merged old spec_helper.rb and new one(It was generated rails g rspec:install ). ENV[

PostgreSQL date() with timezone

烈酒焚心 提交于 2019-12-02 16:34:11
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 Converting gives this: Select (starts_at at time zone 'pst') from schedules where id = 40; timezone ---------

How to set up Postgres database for local Rails project?

China☆狼群 提交于 2019-12-02 14:54:41
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" FATAL: password authentication failed for user "cnh" .... The config/database.yml file looks like this

Error Installing PG Gem on Windows

你离开我真会死。 提交于 2019-12-02 08:22:20
I'm using XAMPP as my installation folder for PostgreSQL 9.3. C:\xampp\pgsql\9.3 And now I'm trying to install PostgreSQL gem using that directory as a reference: gem install pg -- --with-pg-include="C:\xampp\pgsql\9.3\include" --with-pg-lib="C:\xampp\pgsql\9.3\lib" --with-pg-config="C:\xampp\pgsql\9.3\bin\pg_config" But this command failed with errors listed below: ERROR: Error installing pg: ERROR: Failed to build gem native extension. C:/Ruby/Ruby200/bin/ruby.exe extconf.rb --with-pg-include=C:\xampp\pgsql\9.3 \include --with-pg-lib=C:\xampp\pgsql\9.3\lib --with-pg-config=C:\xampp\pgsql\9.

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

橙三吉。 提交于 2019-12-01 09:05:12
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: postgresql encoding: unicode database: store_development pool: 5 username: amysukumunu password: test:

Ruby on Rails+PostgreSQL: usage of custom sequences

一笑奈何 提交于 2019-11-30 13:48:40
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.save on RoR, it tries to do the following SQL: INSERT INTO transactions (transaction_code) VALUES (NULL);

Rails 4.0.1 on Heroku, can't create database

流过昼夜 提交于 2019-11-30 11:30:51
问题 I can't get rake db:migrate to run on my rails 4.0.1 app on Heroku. I'm guessing that I don't have postgres configured properly... but reading the docs on heroku hasn't really helped and I'm not sure what to do. I don't know too much about heroku or postgres. Any help or resources would be greatly appreciated. Let me know if there's anything else I can post. (Also, I'm using devise, if that matters) When I run heroku run rake db:migrate I get this: Running `rake db:migrate` attached to