Questions tagged [rails-postgresql]

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

PostgreSQL is an open source object-relational database system that has the features of traditional proprietary database systems with enhancements to be found in next-generation DBMS systems. PostgreSQL is free and the complete source code is available.

This tag should be used for questions about using PostgreSQL within the Ruby on Rails framework, particularly where the solution desired is to be done "the Rails way" as opposed to directly mucking around in SQL and the like.

485 questions
0
votes
2 answers

psql excluding records base on another table

i am using postgres and wishing to exclude users that are currently in one table from another. at present i am trying do this via the ActiveRecord system within Rails. So i need it to get the ids from my Availability table, then return that id into…
Boss Nass
  • 3,384
  • 9
  • 48
  • 90
0
votes
1 answer

Selecting all rows where an array intersects in postgresql

Currently I'm trying, in a rails 3 application, to select all objects where two arrays have some overlap. I've tried the following: Contact.where("possible_unique_keys && ?" c.possible_unique_keys) Which gives: array value must start with "{" or…
angusiguess
  • 639
  • 5
  • 11
0
votes
1 answer

Get all data from all tables (Postgresql)

data = Program.joins(:program_schedules, :channel). where( "program_schedules.start" => options[:time_range], "programs.ptype" => "movie", "channels.country" => options[:country]). …
sparkle
  • 7,530
  • 22
  • 69
  • 131
0
votes
1 answer

Conflict with Server Version of PostgreSQL 9.2.1 and pg_dump Version 9.1.4 (Rails 3.2.9)

I recently did a clean install of Lion Server on my Mac Mini Server then immediately upgraded to Mountain Lion without copying any of my data from my backup files. Then I reinstalled my Rails applications and deployed them to production (same…
0
votes
2 answers

PostgreSQL query returning multiple rows instead of one

I have two tables: user and projects, with a one-to-many relationship between two. projects table has field status with project statuses of the user. status can be one of: launched, confirm, staffed, overdue, complete, failed, ended I want to…
0
votes
1 answer

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 and year components into separate columns and allow…
0
votes
1 answer

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 FROM crawled_categories WHERE map_id…
Mahmoud M. Abdel-Fattah
  • 1,479
  • 2
  • 16
  • 34
0
votes
2 answers

Why date time different 1 hour when retrieve timestamp data of postgresql from rails

I have a problem that is I migrate database table from rails. In the tables columns timestamps with timezone is also include. When I insert data into database, timestamp columns save current time as (eg. 2012-08-09 12:00:00 UTC+6:30) I think it…
0
votes
1 answer

Postgres Join Query on Rails

I have researched a lot and I can't find the answer for my question. I have the following setup on my Rails app: class Group < ActiveRecord::Base has_many :people # ... end class City < ActiveRecord::Base has_many :people # ... end class…
0
votes
1 answer

Postgres + Heroku Ruby Creation

I have an app running fine on Heroku and I am attempting to connect the app to Amazon's S3 service with Carrierwave. I thought that I had the config files all working for everything, however I am running into an issue when I am creating a picture…
user1470511
  • 339
  • 1
  • 3
  • 14
0
votes
2 answers

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 followed by rails server with no bugs. However, when I…
0
votes
3 answers

Why ActiveRecord caches find(:all) between requests?

I have this in my controller: def frontpage @sections = Section.all end In production environment, the query seems to be cached between requests. Until I restart an app, @sections is always the same. Why and how do I fix this? I should also…
orion3
  • 9,797
  • 14
  • 67
  • 93
0
votes
1 answer

Exchange Data Between Two rails applications

I have two applications App A(rails 2.2.2) and App B(rails2.3.11) and both resides in Heroku. App B is the Upgraded Version(in terms of functionality) of App A.I have some models(say 4) which are similar in context(but their associations varies),…
Sai
  • 135
  • 1
  • 14
0
votes
1 answer

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: # Option a) Ruby logic def some_method id …
Marco
  • 4,345
  • 6
  • 43
  • 77
-1
votes
2 answers

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 tried is: profiles = Profile.find(:all, :include =>…
jeSu valan
  • 11
  • 2
1 2 3
32
33