4
votes
3answers
999 views

Millisecond resolution of DateTime in Ruby

I have a string like 2012-01-01T01:02:03.456 that I am storing in a Postgres database TIMESTAMP using ActiveRecord. Unfortunately, Ruby seems to chop off the milliseconds: ruby-1.9.3-rc1 :078 > ...
2
votes
2answers
2k views

pg gem install on Mac OS Lion with rvm

212-178-13-214:~ igorfedoronchuk$ gem install pg Building native extensions. This could take a while... ...
2
votes
1answer
1k views

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

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 ...
2
votes
5answers
949 views

Postgres segmentation fault ruby gem

I am trying to run this project https://github.com/eLobato/cartodb-rb-client but apparently either my rvm is messed up or pg has a terrible bug. This is the error trace /usr/bin/ruby1.8 -S bundle ...
2
votes
0answers
67 views

Rake migrate Error - database doesn't exist

I have a padrino project that uses data mapper and postgres. When I run padrino rake dm:create it says that the database is created. However, when I run padrino rake dm:auto:migrate, I get the error - ...
1
vote
2answers
484 views

Rails string array and PostgreSQL

I have a Rails model named Container with a column named products. It is a string array as supported by Postgres and the 'postgres_ext' gem. The relevant portion of the GEMFILE is: gem 'rails', ...
1
vote
1answer
262 views

Rails 0mPG::Error: ERROR: invalid byte sequence for encoding “UTF8”: 0xeda0bc

I'm running into an error while trying to write to tweets to my psql database. I've searched the internet high and low (perhaps not well enough) for the answer, with no avail. I've looked at the ...
1
vote
0answers
82 views

heroku pg:transfer - receiving error during upload of postgresql db

I am trying to upload my local database to production and I keep running into the following error while processing: $ heroku pg:transfer --from postgres://username:password@localhost/blog_develo ...
1
vote
0answers
62 views

Postgres periodically slows down on heroku RoR application

I faced with periodic RoR 3 application unavailability. Usually I have 15 minutes unavailability period each day. The problem doesn't relates with application load and I can't find any errors in logs. ...
1
vote
0answers
158 views

pg gem install fails saying version is too old

I am trying to install the pg(postresql) gem for ruby. I am receiving this error: postgres/9.2-pgdg/bin/64/pg_config Using config values from /location/to/install/postgres/9.2-pgdg/bin/64/pg_config ...
1
vote
2answers
138 views

SQL Statement for first row in a “has_many”-association

I am trying to access only the first lines of associated tables. What is the best and fastest way to do this. (Ideally an SQL statement) Associations : class User has_many :addresses class ...
0
votes
4answers
162 views

Batch insertion in rails 3

I want to do a batch insert of few thousand records into the database (POSTGRES in my case) from within my Rails App. What would be the "Rails way" of doing it? Something which is fast and also ...
0
votes
4answers
65 views

How can I sort a list of ActiveRecords by an attribute length?

I have an object like this: irb(main):076:0> hints = Hint.where("sentence LIKE ?","%你%") Hint Load (4.0ms) SELECT "hints".* FROM "hints" WHERE (sentence LIKE '%你%') [ [0] ...
0
votes
1answer
87 views

What's the smarter option: Ruby logic or SQL function?

I needed to write a method that always returns an integer value. If the record is non-existent, the method returns 0 I have a unique index on the columns being queried and came up with two solutions: ...
0
votes
1answer
414 views

Saving time in Ruby on Rails to a Postgres database

I have been having an issue getting the right time to be saved in my database. If I do SELECT NOW() in postgres I will get the right time in EDT. When I do a Time.now in the ruby console I get the ...
0
votes
2answers
34 views

Creating a scope to compare 2 dates

I have a model called Feed that records two timestamps, Last_visited and Last_modified. I'd like to render a list of feeds where last_modified > last_visited I currently have this scope in my model: ...
0
votes
0answers
48 views

$ rails db fails with error, but database is working fine

My Rails 3.2 app is using a PostgreSQL database. It's working great locally. I can migrate and interact with the application through the browser or irb. However when I run $ rails db, I get an error: ...
0
votes
0answers
52 views

rails select method and scope

On my user model I have these scope method class User < ActiveRecord::Base scope :active, where(:deactivated => false) end I am using Amistad gem for handling friendships between ...
0
votes
0answers
66 views

How to insert special characters and keywords into database using `ActiveRecord`

I've exported application code from a Ruby On Rails app that needs to be inserted into PostgreSQL and MySql using ActiveRecord. I've tried different escapes, but no luck. I've tried E and $$ for ...
0
votes
0answers
40 views

Abstracting full text search with postgres

So I have a database on a Rails application that uses postgres for full text searching on one model. I would like to abstract this to do full text searching on several different models with it's own ...
0
votes
0answers
66 views

Complex SQL query Rails

Lesson.joins(:custom_attributes).where("custom_attributes.attribute_name_id = 103 AND cast(custom_attributes.value as float) BETWEEN 0 AND 61").where("custom_attributes.attribute_name_id = 103 AND ...
0
votes
0answers
105 views

rake aborted! undefined method `isthreadsafe' for class `Module' (pg gem)

Still pretty new to rails and postgresql. Anytime I run a rake command I get the following trace: rake aborted! undefined method `isthreadsafe' for class `Module' ...
0
votes
0answers
65 views

ransack search customization using PostgreSQL function

I have an Order model and a Payments model. Order has many Payments. I'm performing a search on the order model using ransack. I have the following association fields for payments in the search ...
0
votes
0answers
53 views

PostgreSQL group_by date and Rails

I'm new so excuse the phrasing. I've created a rails app that uses highcharts and postgresql. The chart shows how many times something has been shared on Facebook. It groups and counts all the ...
0
votes
0answers
57 views

Rails app breaks intermittently due to Postgres explain statement

Rails 3.2.12 app with an external PG DB which has a customers table. I have a local PG DB that has a "geocodes" table. The external customer table may or may not have latitude & lingitude for ...
0
votes
0answers
42 views

ActiveRecord::RecordNotUnique when setting entire collection

Originally Pages were going to have multiple Items, but the specs changed. It's still a has_many relationship but there's a single text field to set it. So in my Page model I have the following: ...
0
votes
0answers
46 views

Rails select by group with Postgresql?

I have a model named Program, which has 'directory_id'、'id'、'user_id' columns, I want to select all the programs group by directory: @programs = Program.select("programs.directory_id, programs.id, ...
0
votes
0answers
126 views

importing csv file into postgresql through Rubymine

I am a newbie at trying to import CSV files into a Postgresql DB through rubymine. I am using rails 3.2.6 CSV file has the following fields: ID,media_code,active_status,comments I have a ...
0
votes
1answer
92 views

Which sources were used to compile gem native extensions

I compiled pg gem with postgres 8.4 sources, but I have reinstalled postgres to 9.0. I have reinstalled pg, but I'm not sure if native extensions were reinstalled. How do I check this?