Open source RDBMS (relational database management system) when used in conjunction with the Ruby on Rails framework.
1
vote
1answer
2k views
Postgres operators for JSON data type using Rails 4
Got a record:
2.1.1 :202 > r.column_data
=> {"data1"=>[1, 2, 3], "data2"=>"data2-3", "array"=>[{"hello"=>1}, {"hi"=>2}], "nest"=>{"nest1"=>"yes"}}
Trying to query inside ...
127
votes
19answers
108k views
PG::ConnectionBad - could not connect to server: Connection refused
Everytime 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 ...
4
votes
1answer
41 views
Rails 5 how to clear or delete production postgres database
I am trying to delete a production database so I can start fresh. When I upgraded to rails 5 from rails 4, it is now protecting the production database from accidental deletion. It shows the following ...
10
votes
4answers
11k views
Rails 4.0.1 on Heroku, can't create database
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 ...
3
votes
1answer
5k views
Replace NULL values in an array in PostgreSQL
SELECT ARRAY[1,2,3] - ARRAY[5,NULL,6]
I am using contrib _int.sql package for array operations in postgresql 8.4
In the above query there is a NULL in right hand side array. Because of this NULL ...
1
vote
1answer
17 views
What vaildations to use for an array data type
PostgreSQL adds other data types to the Active Record default.
See PostgreSQL documentation, List of available datatypes at Stackoverflow and Active Record and PostgreSQL at RailsGuides.
For the ...
34
votes
7answers
37k views
Postgresql adapter (pg): could not connect to server
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/...
1
vote
1answer
33 views
PG::UndefinedTable: ERROR: relation does not exist for Multitenant Rails App
I am working on a Multi-tenant Ruby on Rails App along with another developer. I pulled his branch and received new migration files. I ran rake db:migrate. I visit the index of that controller and I ...
0
votes
1answer
62 views
Postgresql, Rails - could not fork autovacuum worker process: Resource temporarily unavailable
This is happening to me while in my local environment, Mac OSX, every time I start my server - puma - and workers - resque.
The logs don't say anything helpful, just a repeated, "could not fork ...
476
votes
30answers
167k views
Can't find the 'libpq-fe.h header when trying to install pg gem
I am using the Ruby on Rails 3.1 pre version. I like to use PostgreSQL, but the problem is installing the pg gem. It gives me the following error:
demonchand@system-001:~/exercise/personal/pro$ gem ...
1
vote
1answer
24 views
geocode 2 addresses with geocoder gem
I'm trying to geocode 2 addresses which are asked in 1 form.
<%= f.input :kotadres %>
<%= f.input :location %>
Both of them work with Google Autocomplete like this:
<script>
...
0
votes
0answers
20 views
Save a Time object in JSONB
I have a JSONB field in my database defined like this:
t.jsonb :some_data, null: false, default: []
I've tried to save time objects to this field by any of the below methods
my_instance.some_data =...
5
votes
4answers
149 views
Group_by - Ruby/Rails + Postgres
I am pretty new to ROR and Postgre and i'm in trouble to achieve this.
I have a Working_hour Model and a Merchant Model, where merchant has_many working_hours and working_hour belongs to Merchant. ...
4
votes
2answers
9k views
Rails pg gem Incompatible library version
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/...
0
votes
1answer
33 views
GROUP BY PostgreSQL query where I need a column that is not in the GROUP BY clause [duplicate]
I have a database that parallels the 'widget' database below.
widget_id | vendor_id | price
------------------------------
1 | 101 | 10.00
2 | 101 | 9.00
3 | ...
1
vote
1answer
17 views
How should I define a constraint for unique array values within a column in Rails?
I am trying to store some leads in my Rails CRM Application. Here's the sample Lead model.
class Lead < ActiveRecord::Base
belongs_to :campaign
validates_presence_of :name
end
Here's a sample ...
38
votes
4answers
31k views
How to solve privileges issues when restore PostgreSQL Database
I have dumped a clean, no owner backup for Postgres Database with the command
pg_dump sample_database -O -c -U
Later, when I restore the database with
psql -d sample_database -U app_name
However, ...
5
votes
1answer
1k views
JSON data type in Rails4 form_for
how to achieve filling values from JSON PostgreSQL type into nested form in rails?
I have a model like
title :text
description :text
grid :json
Inside properties I want to store a dimension and ...
1
vote
1answer
13 views
Getting an sqlite error when migrating after heroku deployment
So I deployed my app to Heroku and installed gem 'pg' and removed sqlite.
Now getting this error when I migrate locally or on Heroku
Gem::LoadError: Specified 'sqlite3' for database adapter, but the ...
0
votes
1answer
36 views
How to create extension in PostgreSQL db
I want to create an extension, called UNACCENT, when I create my database.
I know this can be achieved with the database command:
CREATE EXTENSION UNACCENT
However, I don't know where to put this. ...
1
vote
1answer
124 views
PG::ConnectionBad: could not translate host name error after running export DATABASE_URL=postgres://$(whoami)
I received this error after running
export DATABASE_URL=postgres://$(whoami)
on the command line. Now when I run the command
$$ rake db:migrate
This is the full error
rake aborted!
PG::...
1
vote
1answer
606 views
Alternative for Serial type in RedShift / PostgreSQL
I am actually trying to make Rails working with RedShift, and facing some issue with Rails default indexes. My work is based on the repo activerecord-redshift-adapter.
By default, Rails use the ...
0
votes
2answers
43 views
Search results ordering based on rating and other values
I am struggling to build a complex ordering algorithm for the search results page.
I would like to order my items by rating (rating count, average rating), but I only want the rating take between 60-...
7
votes
3answers
8k views
Connection refused (PGError) (postgresql and rails)
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....
4
votes
2answers
4k views
Creating a PostgreSQL sequence to a field (which is not the ID of the record)
I am working on a Ruby on Rails app. We are using a PostgreSQL database.
There is a table named scores with the following columns:
Column | Type
--------------+-----------------------
id ...
0
votes
3answers
24 views
Why does Rails .select alias change attributes to lowercase?
In our controller, we are trying to show a video series, which should return JSON similar to this:
{
id: 1,
name: "Series Name",
videos: [
id: 2,
name: "Video Name",
...
1
vote
1answer
295 views
Unable to retreive excerpt from Postgres using pg_search gem
Update
First of all, there is no method "context". That was a word my brain made up at some point and stuck with. Obviosuly I should've been running .excerpt(). Second, I was running the command ...
-2
votes
1answer
91 views
Ruby on Rails - how can I open project with postgres?
last day I have get a ruby on rails project. Know my question: How can I open this project (with postgres).
More information:
My contribution is Windows. Ruby and Rails are both installed.
First I ...
0
votes
1answer
56 views
ruby on rails query on jsonb field does not work
I have a table in the PostgreSQL 9.5 with jsonb column called segmented_data and I have a record with some data in this field
ProjectKeyword.first
=> #<ProjectKeyword:0x007fa83a17e7f8 id: 2201, ...
1
vote
1answer
110 views
Rails postgres hstore: query for a specific key with any of the given values
My question is specific to rails+postgres hstore datatype.
The WHERE IN [1,2, 3] or the rails equivalent Model.where(data: [1,2,3]) works fine for regular columns, but not for hstore.
I have a ...
0
votes
1answer
33 views
`initialize': fe_sendauth: no password supplied (PG::ConnectionBad)
I am new to postgresql. I am trying to use postgresql with ruby on rails. I have just installed postgresql and I have just created my database. But when I try to run postgresql on localhost on port ...
0
votes
1answer
53 views
Sorting issues for Pagination sorting in Postgresql
For pagination sorting am geting duplicated data once load the next page.
For Eg: if a we have full name: Ahern in 1st page and after moving next page also sometimes we can able to see the same record....
4
votes
2answers
799 views
pghero on PostgresApp pg_stat_statements must be loaded via shared_preload_libraries
I have this error
PG::ObjectNotInPrerequisiteState: ERROR: pg_stat_statements must be loaded via shared_preload_libraries
on localhost. Using osx (10.9.5), PostgresApp 9.3.1.0 and pghero gem
...
1
vote
2answers
611 views
How to set default 'uuid-ossp' extension to all migration files using rails?
How to set default 'uuid-ossp' extension to all migration files?
enable_extension 'uuid-ossp'
I'm using ruby 2.1 and rails 4
PostgreSQL
Thanks,
0
votes
0answers
24 views
Cannot connect to psql
I have an error
psql: FATAL: database "deployer" does not exist
When I do
psql
or
psql -U deployer
Before I created user with name deployer and set in pg_hba.conf
local all ...
0
votes
1answer
216 views
Filtering datetime not working when using timezone
In my setup I want to filter Schedule by Activity, City, Date, Starting Time and End Time using select menus.
I've made it work with Ransack:
# db
create_table "schedules", force: :cascade do |t|
...
0
votes
1answer
251 views
Issue constructing a query in Rails using Arel and array attributes
I'm stuck with the query that checks whether two arrays have one or more elements in common.
Since the query is the part of a much bigger query, I need to use Arel to accomplish this. But the &&...
4
votes
3answers
2k views
Cannot remove an index from table in Rails 4 and PSQL 9.3
In my schema.rb I have the following line:
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
When I run \di in psql I get:
Schema | ...
0
votes
0answers
100 views
Memory issues on RDS PostgreSQL instance / Rails 4
We are running into a memory issues on our RDS PostgreSQL instance i. e. Memory usage of the postgresql server reaches almost 100% resulting in stalled queries, and subsequent downtime of production ...
-2
votes
2answers
32 views
Rails - listing most active profile based on number of posts, comments
Profiles can create posts.
Profiles can comment on posts.
Weightage: post = 1, comment = 1.
i need to list people based on consolidated weightage of posts, comments within last month.
what i have ...
1
vote
1answer
198 views
Postgres on Rails FATAL: database “my_app_test” does not exist
I have a new rails environment I'm setting up and I'm having some issues with postgres connecting to the database when running RSPEC tests.
My environment is Ruby 2.2.4p230, Rails 3.2.22, Postgresql ...
0
votes
1answer
1k views
how can I migrate the database dump of MongoDB into PostgreSQL?
I replicate the application using the database as postgresql but later on I came to know that application was using mongodb and I got the dump of the app in json format which was of mongodb.
So any ...
1
vote
2answers
1k views
Postgres server not starting after unexpected Yosemite shutdown
I'm trying to start a rails server but I'm getting this error...
/Users/kweihe/.rvm/gems/ruby-2.1.6/gems/activerecord-3.2.22/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `...
-2
votes
1answer
32 views
Poor performing postgres sql
Here's my sql, followed by the explanation. I need to improve the performance. Any ideas?
PostgreSQL 9.3.12 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4, 64-bit
...
6
votes
3answers
25k views
Rails: rake db:create:all fails to connect to PostgreSQL database
I am trying to create a Rails app that uses PostgreSQL. Here is a description of what I did.
PostgreSQL setup:
I installed PostgreSQL 9.1.3 via the ppa:pitti/postgresql maintained by Martin Pitt. ...
1
vote
2answers
52 views
Rails, ActiveRecord and SubQueries
I have a postgresql database with hourly gas consumption entries.
Now, I need to find the days with the highest consumption for every month.
In plain SQL I'd use subqueries like this:
SELECT
...
-1
votes
1answer
26 views
How to compare dates across two tables where one date is valid until updated?
I have a relatively complicated query to write; we use Postgres. Basically, I have data across two tables:
Table 1: Historical ticket prices
ticket_seller_id | show_id | low_price | created_at
...
2
votes
1answer
65 views
CSV Worker is locking dbase
Bit of a newbie and am completely baffled.
I have a worker that Imports CSV Contacts to save to the Contacts Table (prior to saving, it checks to see if it already exists based on phone or email (...
1
vote
0answers
154 views
Querying nested arrays in Postgres JSON field with Rails
I am using Postgres 9.3 json data type. I want to do a query with data that is nested within the array.
For example, I want to query for users that have all of this interests = ["music", "movies", "...
2
votes
0answers
81 views
Postgres functions not being migrated in test environment (Rails) [duplicate]
I have the following migration:
class CreateNoAccentFunction < ActiveRecord::Migration
def up
execute <<-SQL
CREATE OR REPLACE FUNCTION no_accent(text) RETURNS text AS $$
...