Tagged Questions

1
vote
1answer
37 views

How to use not_if in a chef recipe

I am new to chef so i am a little confused in how the conditional not_if works inside a execute resource. I understand that it tells chef not to execute a command if the command returns 0 or true; ...
0
votes
2answers
24 views

PATH issue installing Postgres on OS X Lion: How do I edit Bash_Profile?

I'm trying to get Postgres up and running on OS X Lion - homebrew - rvm. http://railscasts.com/episodes/342-migrating-to-postgresql After following the above instructions, I ran into the same ...
-2
votes
0answers
35 views

Heroku and pushing the db to the cloud [closed]

Before yeah ago I was able to push my local SQLite db to remote server (heroku) by heroku db:push command. Now I know that I can use heroku-db-transfer plugin for this but it will work with my local ...
0
votes
1answer
22 views

Modifying ruby code to work with Postgresql

I was previously using sqlite3 for my ruby code and it worked fine for the following code def existsCheck( db, id ) temp = db.exec( 'SELECT 1 WHERE EXISTS( SELECT 1 FROM Products ...
-2
votes
1answer
62 views

nginx passenger 502 gateway errors in production [closed]

I have a Rails 3.2.11 production server running two sites: one site is using postgress, and the other one is using mongodb. I’m running Ubuntu 12.10, Nginx 1.2.6, Ruby 1.9.3-p362, Phusion Passenger ...
1
vote
2answers
107 views

Calling a Postgre SQL dump via ActiveRecord

I have a SQL dump which I want to be executed via ActiveRecord. I'm trying this: ActiveRecord::Base.connection.execute(File.read(sql_seeds)) But I get this error: rake aborted! PG::Error: ERROR: ...
0
votes
2answers
34 views

Rails postgres order by custom

I am searching for records using an IN query likes so: Event.where("events.id IN (#{events.nil? ? '' : events.collect(&:id).join(',')})") Which produces output like: SELECT "events".* FROM ...
2
votes
3answers
53 views

How to implement process partitioning on non-integer keys without CRC32?

I'm working on PostgreSQL with a Ruby client and I want to partition a table with SHA-1 hash ids like id ------------------------------------------ ...
-4
votes
0answers
48 views

How do I partition hexadecimal ids into N parts? For example, ffff / 2 -> 8877, 7788 [closed]

I've got hexadecimal IDs like 0d30 I want to split them into N partitions so I can run something like (for N=2): SELECT * FROM foo WHERE id < '8877'; SELECT * FROM foo WHERE id > '7788'; ...
2
votes
2answers
68 views

how to setup postgres db in Heroku

I'm totally new to Heroku and Postgres and I'm trying to figure out how to setup and access the Postgres db in a Heroku Ruby app. I'm not sure how to go about setting this up. I've found some ...
2
votes
0answers
33 views

Ruby script hangs on bad PG connection call

I have a Ruby script that is connection to a postgres database, runs some queries, and then closes/returns data to the user. The script works fine, but if I give it a bad hostname the entire script ...
1
vote
2answers
52 views

First ruby and postgreSql application - getting could not connect to server: No such file or directory

Ruby 1.9.3 on Mac OS X Lion Followed several posts on SO about this topic. Neither helped. Trying to run my first rails and postgreSQL app here. Following this: ...
2
votes
1answer
51 views

An Advanced Query Date Grouping Dilemna

In my Rails app's PostgreSQL DB are records containing hourly prices for the last 10 years: 10(24 x 365) of these: "12/31/2012 01:00:00", "11.99" The following query, groups prices by day, averages ...
1
vote
1answer
39 views

A Database DateTime Value Conflict

I have hourly price data for 10 years. Meaning, 24 prices for each day. The problem is, the price is from the previous hour of trading. So, the source of my data has listed a 24th hour for each ...
2
votes
1answer
40 views

Get average for only a certain date range

In a database with hourly trade prices for the last ten years, the following query will group prices by day, produce a daily average price, and return the average price for every day in the DB: ...
1
vote
1answer
31 views

Save New Object from Query

I have a rails app with a PostgreSQL database with hourly price data for the last 10 years, and I need to get the daily average price for each day saved in a new DB table. This query groups records ...
0
votes
1answer
42 views

Average sales price for each day

I have Rails app with a PostgreSQL DB Sales Table that looks like this: Sales price(decimal) date(datetime) 100.20 11/25/2012 11:00:00 30.43 11/26/2012 03:00:00 ...
1
vote
1answer
37 views

cap deploy:cold production DB is not configured - Postgresql

I am trying run cap deploy:cold to install a rails app with postgresql and I cannot figure out what is meant by 'production database is not configured' or anything else. * 2013-01-03 08:23:26 ...
1
vote
2answers
45 views

Changing the data type of an entire column in a PostgreSQL DB in Rails 3.2.8

I have a DB table for my Rails 3.2.8 app as a PostgreSQL database. In this DB I have a column of type boolean. The column has values filled in. I want to change the values from boolean to all strings. ...
4
votes
3answers
81 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 > ...
1
vote
2answers
59 views

Scope: Sort by difference between two dates

I would like to create a scope which sort data from the closest date to the farthest. For example I have 3 values: <Value id: 1, date: '2012-12-20'> <Value id: 2, date: '2012-12-28'> ...
0
votes
1answer
56 views

Rails sort by column on multiple tables

I'm attempting to do a SQL sort in rails by sorting on a column in multiple tables. Both Event and Featured models have a column called "date". An event can belong_to a Featured. I'd like to be able ...
0
votes
1answer
136 views

:order by has_many association latest entry? how?

rails is so much fun until you need to find a solution and it takes three days with no luck! ;-( How do I order by the latest entry in has_many association for each entry? Explanation: I do a ...
1
vote
1answer
102 views

Result from ActiveRecord::Base.connection.execute(sql) - PostgreSQL

How can I find number of records processed by PostgreSQL after executing a SQL statement using ActiveRecord::Base Connection class? temp_sql = "UPDATE table_a SET column_a ='abc' WHERE column_b = 1" ...
3
votes
1answer
58 views

RSpec - How to mock a stored procedure

Consider the following stored procedure: CREATE OR REPLACE FUNCTION get_supported_locales() RETURNS TABLE( code character varying(10) ) AS ... And the following method that call's it: def ...
0
votes
1answer
34 views

Incorrect Time.now - Not obeying Timezone Setting

Noticed that Time.now is returning the incorrect time (5 hours ahead of EST) ,even though it appears that the config is set to EST. The only way that I've been able to get the correct EST is like ...
0
votes
2answers
42 views

NoMethodError When Using Database Column Aliases in Rails

Undefined method errors when I try to use a column alias for an aggregate (PostgreSQL) Inside my model: class B2bLoginAttempt < ActiveRecord::Base set_table_name "b2b_logins" end Inside my ...
1
vote
1answer
67 views

Prepared Statements Already Exists

I am trying to use the prepared statements in ruby with pg gem. This is how my statement looks like conn.prepare("insert_values", "insert into " + objectName + "(" + headerStr + ") values (" + ...
0
votes
0answers
36 views

Rubyrep with Postgres-> PG::ERROR: Connection is closed when trying to scan

I setup the rubyrep config file with the server information. No extra options. I tested if i could connect to both databases externally with PGAdmin. When I try it out I see the connection spike on ...
2
votes
3answers
71 views

Rails / Postgres: “must appear in the GROUP BY clause or be used in an aggregate function”

I'm using this method: def self.lines_price_report(n) Income.group('date(filled_at)').having("date(filled_at) > ?", Date.today - n).sum(:lines_price) end I'm getting this error in ...

1 2 3 4 5 13
15 30 50 per page