Open source RDBMS (relational database management system) when used in conjunction with the Ruby on Rails framework.
0
votes
2answers
10 views
Retrieving x number of random objects
I'm just trying to load 5 random objects in a rails controller
Thing.all(:limit => 5, :order => "RANDOM()")
Is that the least expensive way to do it?
0
votes
0answers
11 views
why give me this error: psql: FATAL: password authentication failed for user "postgres?
I follow this guide http://www.guia-ubuntu.com/index.php?title=PostgreSQL basically the steps are
1- sudo apt-get install postgresql-8.2 postgresql-client-8.2 pgadmin3
2-sudo passwd postgres, here ...
1
vote
1answer
16 views
PostgreSQL: Need to perform Row operation
I'm new with PostgreSQL. I would like to perform a row operation on my table.
For example consider this table output :
Record | Accesories | Used
Joy | Laptop | 500
Joy | Android ...
-2
votes
0answers
25 views
recovering postgresql database with pg_xlog without a base back-up file
I accidentally removed the all rows of a postgresql database.
The problem is that there is no back-up file except the data saved in data/pg_xlog/* in forms of binary.
Here, the structure and the ...
0
votes
1answer
17 views
Grouping in Ruby on Rails using PostGres
I have the following line of code which works in sqlite, but in PostGres doesn't:
@income_by_category = SoldCategory.group(:category_name).having("branch_id=?", @branch_id).sum(:total).to_a
It's ...
0
votes
1answer
9 views
DB query from a belongs_to relationship
I have a model: Animal
belongs_to :owner
I have a model: Owner
has_many :animals
Owner has a boolean attribute active
def self.not_active
where('owner.active == ?', false)
end
The above ...
0
votes
2answers
30 views
rails 4 undefined method `sql_type' in migration
I have following migration:
class CreateTariffs < ActiveRecord::Migration
def change
create_table :tariffs do |t|
t.string :name
t.decimal :amount, precision: 10, scale: 6, ...
2
votes
3answers
65 views
Using postgres arrays in Rails 4, how do I return an array of all the unique items in the array?
My migration looks like this:
create table :posts do |t|
t.string :tags, array: true, default: []
end
How can I get an array of all the unique tags stored under tags in all posts?
5
votes
2answers
227 views
Enabling Tiger Geocoder in postgis version 2.1
I have used homebrew to update to the most recent version of postgis. (2.1)
brew unlink postgis
brew install postgis
I then have created a migration to alter the postgis extension to 2.1
rails g ...
0
votes
1answer
22 views
Heroku Postgres Database
I'm completely confuse about Heroku Postgres Plan. Please help.
When I check for PG info, using:
heroku pg:info
It's showing:
=== HEROKU_POSTGRESQL_BRONZE_URL
Plan: Basic
Status: ...
0
votes
1answer
35 views
Paginating joined results with calculated columns
We are calculating statistics for our client. Statistics are calculated for each SpecialtyLevel, and each statistic can have a number of error flags (not to be confused with validation errors). Here ...
0
votes
1answer
23 views
Adding Default Value to Column Depending on the Value of Another Field in A Model In A Rails 3.2.13 Database Migration
I already have a date field (string) in my model. I plan to add other string fields with different long date formats to use in a text search related to the existing date field. This is to facilitate ...
0
votes
1answer
47 views
Retrieve the nextval from a sequence using activerecord in Ruby on Rails 3.2.14 / Ruby 2.0.0 / PostgreSQL 9.2.4
This should be SO simple. I want to retrieve the nextval of a sequence... it's not a default value... it's not a primary key... it's not a foreign key. In rare cases, I need a sequence number for a ...
2
votes
0answers
135 views
How to make an array sum of month from Postgresql query to Rails 3
I'm new in programming but here's the thing: I'm trying to make rails app which takes data from postgresql database and shows summary in jqPlot chart, but I am having trouble with my queries. I need ...
0
votes
1answer
28 views
Postgre SQL incorrect syntaxt near If
I'm trying to create function but it's having error at If statement don't know what's the problem with it.
CREATE FUNCTION uspgetcountrylistwithpagenumber(IN "PageNumber" integer, IN "PageSize" ...