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
19 views

Rails Join Table Issues

In my app there is an Athlete and this athlete has many sports (joined through a user_sports table). Now, each sport has a position (Pitcher, Third Base, etc). Where I am stuck at is trying to ...
0
votes
0answers
77 views

Ruby on Rails: Postgres Relation 'lists' does not exist

I'm getting a weird error. I had sqlite3 working and now switching over to postgres, i'm getting this error. I have migrations, and I had to add a new column. create_ideas migration class ...
0
votes
0answers
55 views

Rails order and kaminari pagination

I am using kaminari gem for pagination in my rails 3 application on my album controller @albumcomments [email protected](:created_at).reverse_order.page(params[:page]).per(4) and I am ...
0
votes
0answers
54 views

Can't configure postgres on local machine to work with rails application

I have an existing rails application. My database and application seem to work fine on the remote database (I made changes on my local machine but am still connected to the remote database), but I ...
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 ...
0
votes
4answers
160 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
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
1answer
49 views

How do I .group and .sum in a rails model using Postgres?

I have a functioning method in my development environment (SQLite) that looks this: def self.ytd Production.find( :all, conditions: ["year == ?", Time.now.year], select: "carrier_id, ...
0
votes
1answer
158 views

Import data from text file into PostgreSQL. “Postgres_Copy” Gem

I am using PostgreSQL with ruby and rails app and have Postgres_copy gem installed https://github.com/diogob/postgres-copy I have hotels table and want to import text file using function pg_copy_from ...
0
votes
1answer
187 views

Heroku rake db:migrate aborted with 'PG::Error:'

I'm trying to run my app on Heroku, and I can't get past the 'rake db:migrate' command. I keep getting this error: rake aborted! An error has occurred, this and all later migrations canceled: ...
0
votes
1answer
147 views

Get all data from all tables (Postgresql)

data = Program.joins(:program_schedules, :channel). where( "program_schedules.start" => options[:time_range], "programs.ptype" => "movie", ...
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] ...
1
vote
1answer
92 views

Grouping a timestamp field by date in Ruby On Rails / PostgreSQL

I am trying to convert the following bit of code to work with PostgreSQL. After doing some digging around I realized that PostgreSQL is much stricter (in a good way) with the GROUP BY than MySQL but ...
2
votes
1answer
229 views

Drop or Delete Schema Postgresql via controller Rails

I have multi-tenant application rails with postgresql, i want to drop schema (schema name = subdomain) and delete or table on schema. primitive code on controller, wkwkwk. accounts_controller.rb ...
1
vote
1answer
154 views

PostgreSQL Error for Select Distinct in Rails

On Mysql it works correctly. PG::Error: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list LINE 1: ) ORDER BY programs.rating DESC, program_sc... ^ : Query: ...
2
votes
1answer
236 views

Cannot create test database in rails 3.2 with postgres

This is an extremely strange one. Im trying to do a simple rake db:test:clone or create and no matter what I do, from clearing the gemset to trying all sorts of database.yml configs, Im getting the ...
8
votes
3answers
6k views

Postgresql via homebrew vs. mountain lion OS X

This is bothering me to no end. I'm setting up a Rails 3.2 environment with Postgresql on my Mac with OS 10.8.2 (Mountain Lion). I basically followed the directions in the Railscast, and installed ...
0
votes
1answer
62 views

Sorting by dateparts in rails

So I am using jquery datatables and the column filtering extension to sort, page and filter table date on a Rails project. One unusual thing about my table is that I need to break up month&day ...
0
votes
0answers
176 views

Stuck on postgres batch update query

So I am experimenting with Postgres batch updates in my rails apps to speed up how a background calculation is run. I am getting really close, but there is just 1 error I just can't seem to fix. Here ...
0
votes
1answer
37 views

how to run this custom complicated query in rails3

How could I run the following query in rake task ? DELETE FROM crawled_categories WHERE id NOT IN ( SELECT id FROM ( SELECT DISTINCT(site_id, parent_category, breadcrumb), max(id) AS id ...
0
votes
2answers
1k views

How can I create a Postgres user and database whenever I create a new rails app?

I have followed this really helpful tutorial: http://blog.willj.net/2011/05/31/setting-up-postgresql-for-ruby-on-rails-development-on-os-x/ I would really like to run rails new myapp and have the ...
3
votes
0answers
139 views

Error trying to load structure with rake db:structure:load, “schema_migration” does not exist

I'm running rake db:structure:load but after loading all structure it fails to insert versions at schema_migrations. Looks like PostgreSQL don't know about recently created tables. Already googled ...
0
votes
2answers
458 views

Strange PostgreSQL errors when trying to start a rails server on Mac OS X

I want to get a rails application working with PostgreSQL, but something strange is happening. My friends were able to install PostgreSQL and execute: sudo su su postgres createdb development ...
4
votes
3answers
2k views

Rspec: How to supress warnings and notices when running tests?

I was using Mysql database before and decided to switch to Postgresql and now, when I run my tests using rspec, I getting a lot of warnings and notices. WARNING: there is already a transaction in ...
1
vote
1answer
227 views

Newly assigned Sequence is not working

In PostgreSQL, I created a new table and assigned a new sequence to the id column. If I insert a record from the PostgreSQL console it works but when I try to import a record from from Rails, it ...
1
vote
1answer
110 views

Rails Model associations but different databases

I am building an app which uses a mysql and a postgres database. I'm using postgres because of postgis as this app is location based. Postgres only has one database Places whereas mysql contains all ...
3
votes
2answers
6k 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. ...
5
votes
1answer
123 views

Use “database users” to authenticate in Ruby on Rails

I have a PostgreSQL database that I access from various locations, and would like to add an interface with Ruby on Rails 3. For authentication I need to login users with the same credentials used to ...
1
vote
0answers
399 views

rails 3 dumping PostgreSQL database into schema.rb ignores primary keys

rake db:schema:dump Changes: create_table "accounts", :force => true do |t| ...some columns... end Into: create_table "accounts", :id => false, :force => true do |t| t.integer ...
5
votes
3answers
4k views

rspec returns “PG::Error: ERROR: relation ”table_name“ does not exist”

Environment is REE(2011.12) on rvm, rspec 2.8.0, rails 3.0.6, and pg 0.13.2. Using PostgreSQL 8.3.17 on CentOS 5.6. The db:migrate have work correctly. But rspec have got following error. 1) ...
1
vote
3answers
2k views

Rails Scope: Select Distinct Title With Values

I'm having trouble with an SQL query in a scope. I need to return a collection of unique Project.titles and their accompanying ids for use in a form. I can get the distinct title using scope ...
0
votes
2answers
226 views

How to create a non-system user when installing Postgresql 8.4 with Rails 3.2.1 on Ubuntu 10.04 VM?

Today I tried to install Rails 3.2.1 with Postgresql 8.4 on my local Ubuntu 10.04 VM. I basically followed the instructions from ...
0
votes
0answers
75 views

Using Array for :conditions isn't working with my app on Heroku

I've just deploy my test app on Heroku. Everything was working fine except for one, WHERE clause. My app has a plugin that I created myself and it add many features to every models in my app. One ...
0
votes
1answer
54 views

Hartl rails 3.0 sample 'operator does not exist'

I'm working more on my first live Rails app using 3.1.0 with M. Hartl's guide and Postgres. I've moved onto Chap 10 in working in the authentication. Instead of pages, I'm using openings. Apart from ...
1
vote
3answers
342 views

How to efficiently search for last record matching a condition in Rails and PostgreSQL?

Suppose you want to find the last record entered into the database (highest ID) matching a string: Model.where(:name => 'Joe'). There are 100,000+ records. There are many matches (say thousands). ...
2
votes
1answer
283 views

How to combine these two PostgreSQL statements into one for Rails 3 application?

I have two PostgreSQL statements that I would like to combine in my RoR application. The first SQL statement returns a link where the link contains two specific tag_ids. SELECT link_id, count(*) as ...
3
votes
2answers
226 views

How do I lock records in Rails 3 for a specific amount of time?

What I want to do is basically have a user obtain the lock on a record and have it for a specific amount of time so they can make changes to it, like wikipedia. So lets say a wikipedia article gives ...
1
vote
1answer
2k views

Rails - How to add a BLOB column using ActiveRecord?

I need to create a BLOB column to store some text content. I have read somewhere that I need to do the following: class AddVersionCommentToMetaData < ActiveRecord::Migration def self.up ...
2
votes
2answers
3k views

has_many & belongs_to migration with foreign keys and database constraints in postgres?

I've searched several questions about migrations and their answers, but I didn't find a satisfactory solution. I want to use simple has_many and belongs_to relationships like class User < ...
0
votes
1answer
1k views

How to migrate a boolean field in MySQL to PostgreSQL in Heroku?

I have a application, running with MySQL in my local machine. There is a field I define as boolean in Rails, which is represent in 0 or 1 in MySQL. I am now trying migrate to Heroku, which is using ...
0
votes
1answer
232 views

What is causing PGError: ERROR: there is no parameter $1 in my Rails app

I started getting this error on edit/show of a Rank object. I've never seen it before and am not sure how to resolve it. Any input?
3
votes
1answer
1k views

postgres/postgreSQL FATAL: database “ew_dev” does not exist

I'm trying to get echowaves up and running on mac os x 10.6.4 and I followed all the instructions here https://github.com/echowaves/echowaves successfully but when I run rails s I get the following ...
0
votes
1answer
290 views

Why won't this spec/controller test pass? It did before… (Rails, RSpec)

The following is in my spec/controllers/superadmin/users_controller_spec.rb: describe "GET index" do it "receives the where action twice" do User.should_receive(:where).twice get ...
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 ...
1
vote
1answer
315 views

Multiple database users On a Rails 3 app

i want to know how do i set an http log in form to send that user and password to the database.yml file, so with that user and password, log into the database. This because i have multiple database ...
1
vote
1answer
698 views

Postgresql (Rails 3) merge rows on column (same table)

First, I've been using mysql for forever and am now upgrading to postgresql. The sql syntax is much stricter and some behavior different, thus my question. I've been searching around for how to merge ...
97
votes
8answers
38k views

Can't find the 'libpq-fe.h header when trying to install pg gem on ubuntu

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
3answers
1k views

rake aborted! no such file to load — sqlite3

I've set up a new rails3 app and my gemfile is below source 'http://rubygems.org' gem 'rails', '3.0.0' gem 'nifty-generators' gem 'pg' gem 'authlogic' gem 'jquery-rails' gem "mocha", :group => ...

1 2
15 30 50 per page