0
votes
1answer
28 views

SQL Database/.SQL File to CSV File

I'm writing an application with Ruby on Rails that will take CSV files and migrate data into postgresql databases, however, all of my data is stored as .SQL files or as databases on an MS SQL 2008 ...
0
votes
1answer
19 views

Does setting ActiveRecord text limit save DB space?

Does setting ActiveRecord text limit actually save DB space? The purpose of having a string with a max at 255 or 256 is to save on storage usage. With text having a large amount of capacity, does ...
0
votes
1answer
13 views

Missing from-clause entry for table / undefined table error

This works locally in SQLite, however when I push to heroku I get this issue. This issue only occurs when I end the statement in ORDER BY, otherwise it doesn't give me an issue. It's like it breaks ...
0
votes
0answers
29 views

Will Amazon RDS for Postgres be as convenient as using Heroku Postgres? [on hold]

I'm currently running a Heroku Rails app and our Postgres DB has grown to a data size of 50GB, and our DB cache hit rate is at 93%. We're on the legacy Ronin ($200/month) plan (1.7GB) and probably ...
1
vote
1answer
16 views

Rails + Postgres Relation Issue With Custom Foreign Key

I'm in the middle of a migration to Postgres from MySQL and i'v hit an issue that I just can't solve. I'm sure there is simple answer, but i'm stuck. The Problem I have a step model that belongs to ...
0
votes
0answers
8 views

VMWare Fusion based browsers ( Chrome, IE ) do not load my Mac hosted site

This occasionally and randomly works. Maybe 1 out of 100 attempts. But when I try to access my localhost, I get a blank white screen. My logs from my server show that a connection has been made : ...
0
votes
1answer
24 views

Heroku transfer data between remote databases, clear syntax example

I have a staging app full of data that I want to use to populate my currently empty production database. Currently I am trying to use pg:transfer. What is the correct syntax to use? Addresses: ...
2
votes
2answers
32 views

Get all associated objects on self join objects and its children

I am trying to find all the associated friends with my Person, self-join, record and all its children. Here is an example I am trying to run. I have a Person record, lets call it @person, that has 4 ...
0
votes
0answers
19 views

Why won't my serialized PostgreSQL array save to the database?

My schema looks like this: create_table "products", force: true do |t| t.string "elements_list", default: [], array: true end I am using Rails 4 and aiming to use PostgreSQL's array column ...
0
votes
0answers
10 views

Rake Database test and Development With PostGis

Ok i have been dealing with tring to get my database to create with postgis. I did not install postgis. I took over the site after built it is running postgis 2.0 I have read over this information ...
0
votes
1answer
22 views

offset not selecting distinct values

I debugged my query for some time now. I narrowed the problem down to this: I've got a local database with 44 movies. Running the query: ...
0
votes
0answers
33 views

Should table be dropped when deleting obsolete Model in Rails?

I want to delete an old Model as part of keeping a Rails application's code clean. I would also like to ensure I have a backup of the data associated with that Model (it is persisted using ...
0
votes
0answers
15 views

Can I use encoded string for table IDs instead of monotonically increasing integers in my Rails?

Environment Rails 4.0.4 Postgresql By default the model implements monotonically increasing integers, if there a way to tell rails to use something else, like encoded string, just like in MongoDb? ...
1
vote
2answers
22 views

Order on count of associated record

So I have got a little further in a problem I have been having, I have three models Trader/Location/Service....a Trader HABTM Locations and a Trader has many Services. For a Location instance I am ...
1
vote
0answers
14 views

Best practices for using pgcrypto PGP encryption with Heroku and Rails

Are there any security best practices for using Rails and Heroku Postgres with pgcrypto's public key PGP. The naive and direct way seems to be to store the private key and password using Heroku's ENV ...
0
votes
0answers
26 views

Duplicate records created on certain actions in a Heroku Rails app

I'm having an issue where duplicate records are being created in what is seemingly a race condition, since I run a dupe check hooked into before create. In this case, I'm creating prospects out of ...
0
votes
0answers
18 views

Mongoid Active-Record Association

I'm writing a web app using rails 4 which utilizes both PostgreSQL and MongoDB (via Mongoid) as back-stores. The associations between these stores are quite lightweight, but I still need to enforce ...
1
vote
4answers
27 views

How to write this ActiveRecord Query using Join instead of subquery in Rails 4

Consider the following: class User < ActiveRecord::Base has_many :events end class Event < ActiveRecord::Base belongs_to :user #this user is the event owner has_many :members end class ...
0
votes
0answers
10 views

possible to create postgres proc on heroku?

I am trying to create a distance function on heroku. Here is the function: CREATE LANGUAGE plperlu; create or replace function distance_in_km (numeric,numeric,numeric,numeric) returns numeric as ...
0
votes
1answer
17 views

POSTGRES WINDOWS “server not listening” (beginner)

When logging to PGadmin and trying to access my databases (linked to a Rails app) I get an error such as 'server not listening'. My password doesn't work Yet when unsinstalled and reinstalled ...
1
vote
2answers
43 views

undefined method `model_name' for ActiveRecord::Relation::ActiveRecord_Relation_Link:Class

I'm trying to follow some lessons on creating a list type of forum. Now the problem is to the Destroy function: undefined method `model_name' for ...
0
votes
2answers
34 views

Rails: database queries too slow for scope that depends on join with another table

I'm building a Rails 4.1 app (using Postgres as my database) which has a couple of models set up in the following manner: class Components < ActiveRecord::Base has_many :compositions scope ...
0
votes
3answers
34 views

How to concatenate string fields to one field with a delimiter in rails 4 application?

I have multiple checkboxes in form, in which I store the results of every field in their corresponding temporary fields which I specified in model with attr_accessor: attribute. I want to join the ...
0
votes
0answers
25 views

Custom options for a custom database column in Rails

I'm creating a custom extension for the PostgreSQL database adapter to add geometry as a data type. I've been able to successfully add geometry as a column type but the options don't seem to stick. ...
1
vote
1answer
29 views

How to retrieve only updated records based on `updated_at` column in Active record

I am trying to retrieve all the records from table which are updated. Here i am considering updation of only updated_at column and no other column. As whenever a new record is created, both ...
0
votes
1answer
27 views

Using find_or_create_by to update table

I have a table that I am trying to update after I have made changes to the url column. Currently, the data is seeded into the databse when I run rake db:seed, but if I make changes to the csv, in this ...
1
vote
2answers
17 views

Importing Data from CSV to PSQL

I am trying to import data from a CSV to a PSQL database. I found a good example of how to copy the data from the csv on stack overflow, which looks like the following (only the file path is ...
1
vote
1answer
19 views

Rake is aborting because undefined method `inet'

Where and how should I define inet? It's a valid postgreSQL data type. http://www.postgresql.org/docs/8.4/static/datatype-net-types.html rake db:migrate == CreateSysHosts: migrating ...
0
votes
1answer
14 views

Postgresql change the year range and input order

I have a date_of_birth field with type date and I need to correct the following two issues: The year range is limiting to 2010..2020 The order of the fields is YYYY - MM - DD and I would like it to ...
0
votes
1answer
19 views

Rails 3.2 frequent postgres prepared statement already exists errors

I've been digging around stackoverflow trying to find others who get these prepared statements already exists errors. In most cases configuring unicorn properly with the after/before fork resolves ...
2
votes
1answer
33 views

When to add records to a user_posts table to track 'likes'

I have a Groups model that has_many Topics. The Topics model has_many Posts, my Users model only read posts etc. I also have a users_posts model which is used to keep track whether a user has read the ...
0
votes
0answers
20 views

Group by Error: PG::GroupingError: ERROR: column must appear in the GROUP BY clause or be used in an aggregate function [duplicate]

I have a column utc_time where stores unix timestamp, and I want to group by date, But got errors. def self.memory_info_daily(test_id=1) self.unscoped .where{ name =~ 'MemoryInfo' } ...
1
vote
2answers
17 views

How to group by hourly or 15 minutes using postgres

I tried to group by hourly, but failed. Here my query self .where{ name =~ 'MemoryInfo' } .where{ sony_alarm_test_id.eq(test_id)} .group("DATE_PART('hour', utc_time )").count The ...
0
votes
0answers
13 views

Ruby On Rails schema_search_path not working in centos 6.2

I have a connection, but It not get schema_search_path on CentOS. development: adapter: postgresql encoding: unicode database: data_name host: localhost port: 5434 pool: 5 username: ...
0
votes
1answer
14 views

Rails ActiveRecord polymorphic associated relationships

I've made a Rails app where I have tags, which I can use to tag various other models, however unlike a normal polymorphic relationship there is only 1 tag record for each tag name and then I used a ...
0
votes
0answers
24 views

My project Ruby On Rails cannot install gem postgre in CentOS 6.2

Although many sources of references from stackoverflow but my problem has not been resolved. When I run My project (ProjectJapanFull_New) on window server it no problem, but when I switched it to ...
0
votes
2answers
31 views

PostgreSQL - must appear in the GROUP BY clause or be used in an aggregate function

This query works locally, but doesn't work on Heroku for some reason. 2014-06-26T00:45:11.334388+00:00 app[web.1]: PG::GroupingError: ERROR: column "conversations.updated_at" must appear in the ...
2
votes
3answers
62 views

Heroku Application Error when using Heroku create command

I am following a tutorial at http://onemonth.com where I created my rails app. I was asked to use Heroku to get my app live online. I followed the steps for linking my Github account to Heroku via the ...
1
vote
1answer
14 views

PostgreSQL DATALINK type in Rails 3.2

I want to use DATALINK type (https://wiki.postgresql.org/wiki/DATALINK) in Rails 3.2, but it is not supported. With this migration file: def up change_column :images, :image_url, :datalink ...
0
votes
2answers
19 views

Missing Javascript assets on production deployment of Ruby on Rails app, all is fine under WEBrick

Missing Javascript assets on production deployment of Ruby on Rails app, all is fine under WEBrick. I have this standard Rails app I'm trying to deploy. The app loads fine but all Javascript has ...
0
votes
1answer
25 views

Rails model user ID PG ERROR: NotNullViolation

I'm using rails 4, postgres 9.3 and devise, and at the moment of sign up an user, I'm getting the error of : PG::NotNullViolation: ERROR: the null value for column « usuario_id » violates the ...
0
votes
0answers
19 views

Database encryption options for Ruby on Rails hosted on Heroku

One of the clients I'm working with is requesting that I encrypt my database. The problem is, none of my other clients need or care about this. I am wondering two things: How costly (performance) ...
0
votes
1answer
30 views

Optimising Sidekiq, Redis, Heroku and Rails

So I'm trying to process a CSV file via Sidekiq background job processing on a Heroku Worker instance. Whilst I can complete the process, I feel it could certainly be done quicker/more efficiently ...
0
votes
1answer
31 views

ActiveRecord Postgres adapter generating invalid SQL WHERE clause: WHERE(“fieldname”)

ActiveRecord 4.1.1 is generating some peculiar SQL on save that postgres is choking on: SELECT "projects".* FROM "projects" WHERE ('uid') LIMIT 1 PG::InvalidTextRepresentation: ERROR: invalid ...
1
vote
1answer
22 views

Heroku nil class error

I just pushed my local Rails 4 app to Heroku, and I've got a strange error. As is often the case, it works fine locally with no issues. I think that the Heroku DB / environment is basically the same ...
0
votes
1answer
20 views

rails 3.2 / postgres - how cast SUM() to return an integer not string?

Postgres aggregates like SUM(foo) return a string, even if foo is an integer. How do I cast the sum to an integer so the resulting array of relations contains an integer not a string? I tried to ...
0
votes
1answer
16 views

How do I write a has_many :through a scope by a particular ID?

My model reads as so : class Registration < ActiveRecord::Base has_many :registered_courses has_many :courses, through: :registered_courses has_many :sections, through: :courses The ...
0
votes
0answers
16 views

ActiveRecord::ConnectionTimeoutError w/ rails, sidekiq & postgresql

I have a rails application that is running postgresql and sidekiq. When scheduling a large amount of background jobs that take ~20 seconds each to complete I get the following error ...
0
votes
0answers
18 views

PG::TRDeadlockDetected: ERROR: deadlock detected

I am restarting 8 puma workers via bundle exec pumactl -F config/puma.rb phased-restart what works fine. Now I am getting more and more postgres errors: PG::TRDeadlockDetected: ERROR: deadlock ...
0
votes
1answer
44 views

Postgres query for 10 steps in a range

We have a RAILS app with Postgres as database and have a use case for drawing a graph over a range of values. Unfortunately the range is a decimal, so I am not able to use the generate_series function ...