Open source RDBMS (relational database management system) when used in conjunction with the Ruby on Rails framework.

learn more… | top users | synonyms

4
votes
1answer
50 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 ...
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 ...
1
vote
1answer
34 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 ...
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
1answer
69 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 ...
0
votes
0answers
23 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
150 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
36 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 ...
1
vote
1answer
14 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
37 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
143 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::...
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-...
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", ...
-2
votes
1answer
95 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 ...
1
vote
1answer
116 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
57 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, ...
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....
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
0answers
104 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
203 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 ...
-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 ...
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 ...
2
votes
1answer
66 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
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 ...
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 ...
0
votes
0answers
51 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, ...
1
vote
1answer
137 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
1answer
25 views

What is the role of -s flag in creating user

I am trying to a create a user in postgres, I did the following. sudo -u postgres createuser mystore But I found out that I should use -s flag while creating the user, So my question is what is ...
2
votes
2answers
252 views

Problems with heroku rake db:reset

I have a problem, I pushed my app to github and I made the deploy with heroku, everything was ok, but when I run heroku run --app myapp rake db:reset (to populate the database on heroku) I found the ...
0
votes
1answer
231 views

Rails 4.2 OR scope using includes/joins

Given a List model with relationships: has_many :list_group_memberships, dependent: :destroy has_many :groups, through: :list_group_memberships has_many :users, -> { unscope(:order).uniq }, ...
0
votes
1answer
56 views

How to Delete all duplicate rows in postgres sql based on 3 duplicate columns and out of that keep max and second max date value rows

I have a table temp it has 118507658 records . I need to clean up this table based on below condition. If three columns that is (dp_content_definition_id,dp_order ,value_scope_id) are identical then ...
0
votes
1answer
45 views

Check that record doesn't exist/retrieve existing record active record

This question has two parts: Consider an active record relation that has a Student - name:string, favorite_class:references and FavoriteClass name:string, abbrev:string. First question: When ...
1
vote
2answers
55 views

Better to have a field “City” or a table “City”?

I'm making a website with Ruby on Rails and I'm thinking of the database structure. The website is very simple, we make a list of many places, and tell from which city they are. For example "Tour ...
1
vote
1answer
34 views

Pgagent and Postgis are not seen in pgAdmin?

I have a rail project and I tried to add checkin property to my app. I have already install Postgis and pgAgent tool to my Postgres server from ApplicationStackBuilder but I can not find these tools ...
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
220 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
0answers
50 views

Weird results using distinct() and count() methods on apparently similar code

The following strange behavior has been spotted with Rails 4 (Rails 4.2.2/ruby 2.2.1) and PostgreSQL 9 (PostgreSQL 9.4.4). Keeping in mind that grouping without aggregate expressions effectively ...
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 $$ ...
0
votes
1answer
79 views

Getting PG duplicate table error on deploy

I want to deploy from a branch in which I have three new migration files. However, on deploy, I get an error. This is the log output: DEBUG [50e68bc0] == CreateLimitGroups: migrating ==========...
2
votes
4answers
130 views

Rails: Optimize querying maximum values from associated table

I need to show a list of partners and the maximum value from the reservation_limit column from Klass table. Partner has_many :klasses Klass belongs_to :partner # Partner controller def index ...
0
votes
1answer
69 views

Why does the where() method run SQL queries after all nested relations are eager-loaded?

In my controller method for the the index view I have the following line. @students_instance = Student.includes(:memo_tests => {:memo_target => :memo_level}) So for each Student I eager-load ...
0
votes
0answers
80 views

postgis_tiger_geocoder create extension fails with geometry does not exist error

I have a rails app and I use postgis in my app to store the spatial data and now I would like to make use of the reverse geocode function in postgis and there by looked for the options and found that ...
0
votes
2answers
301 views

How to submit a string array in a form Rails 4.2

I has a message model with a string array attribute recipients. Here's what my messages_controller.rb looks like def new @message = Message.new @message.attachments = params[:attachments] end def ...
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 `...
1
vote
1answer
214 views

Rake tasks seem to ignore database.yml configuration

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 ...
1
vote
1answer
1k views

Query an array of json with Active Record (Rails 4/postgresql9.4)

I have Deal model who has an attribute called 'info' with this structure: Inside the column 'info' on Deal: Deal1.info = [{"deal_id":"4","text1":"qqq","text2":"sqsq","image1":"sqqs","video1":"sqsq"}...