Open source RDBMS (relational database management system) when used in conjunction with the Ruby on Rails framework.
0
votes
0answers
23 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. ...
0
votes
1answer
22 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 | ...
121
votes
18answers
99k 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 ...
1
vote
1answer
14 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 ...
36
votes
4answers
28k 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
26 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
35 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
592 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
42 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-...
6
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
21 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
281 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
54 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 ...
461
votes
30answers
160k views
Can't find the 'libpq-fe.h header when trying to install pg gem
I am using 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 install pg
...
0
votes
1answer
51 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
83 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
28 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
38 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
597 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
567 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,
32
votes
6answers
35k 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/...
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
191 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
235 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 | ...
10
votes
4answers
10k 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 ...
0
votes
0answers
64 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
118 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
564 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
24k 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
50 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
60 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
139 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 $$
...
10
votes
2answers
4k views
How to use ActiveRecord outside Rails?
I'm building a Rails application based on hexagonal architecture.
One of my adapters is storage adapter (maintained as a gem) that manages access to database and provides simple interface for rails ...
19
votes
3answers
31k views
How to set up Postgres database for local Rails project?
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 ...
0
votes
1answer
1k views
Querying a PostgreSQL multi-dimensional array data type in Rails 4
I am using a PostgreSQL multi-dimensional array to mimic an array of hashes, and I am looking for a way to locate a record by a key-value pair in that array like e.g ["key1","value1"]. An example ...
4
votes
1answer
755 views
Find values greater than using hstore and rails
I am storing product information, including the release year of the product, using hstore and postgresql in rails. Now I would like to be able to query for all products that was released before or ...
2
votes
0answers
99 views
is it possible to index html content in postgresql full text search?
I have a bunch of html pages. The idea is to allow users enter keywords to search through these html pages. only html pages that match the criteria will be store for later references. I knew that ...
1
vote
2answers
27 views
How to get unique value after removing space and group by some different column in postgres
I have a table like
id type note
1 A ab cd
1 B cdef
1 A abd
1 A abcd
I want to get all the unique notes after removing space so my result will be like this
id type note
1 A ab ...
1
vote
1answer
132 views
'pg' works locally, but not when deployed to Heroku
pg 0.18.4 works just fine in my development environment but not in Heroku. Locally, it first failed when I just ran bundler install but then succeeded when I manually ran gem install pg -v '0.18.4'. I ...
0
votes
0answers
40 views
Ruby jbuilder view inefficiently rendering jsonb postgres field
Jbuilder 2.3.2, in a Sinatra app with postgres 9.4
(I tagged Rails 4 because this is a Jbuilder question, and SO tag jbuilder is for questions about the Java IDE)
jsonb field in a Postgres table, ...
5
votes
2answers
400 views
Building and storing complex SQL query for later editing
I am using Rails 3.2.8 to build a "product set" builder that mirrors Google Analytics' Custom Profile builder. For example, a user may define a product set as follows:
(Category = 'Printers') and ((...