0
votes
0answers
33 views

Radio button selection Rails - Across partials

I am trying to allow the user to pick one of the predictions out of the 7/8 (which are loaded with the predictions partial) as a double match (double points for anyone interested). I can't get it to ...
0
votes
0answers
61 views

Rails select NoMethodError in Messages#new

I'm trying to put on a select box the Users who will receive the message. What we have is one table named Messages, one named Users and one named Friendships, on message table we have user_id (sender) ...
1
vote
1answer
44 views

Group by two columns, to get uniq result

I want to group the results from one table by two column: created_at p_id, I need to group it by p_id because I need unique values, and I tried using distinct in order to do that but in my case didn't ...
1
vote
1answer
48 views

Postgres insert error in ActiveRecord

For some reason, I cannot get ActiveRecord to correctly format the insert statement when using an array type column. It seems to want to escape the Postgres notation: {"val1", "val2", "val3"} into ...
0
votes
0answers
41 views

Rails 3.2.13 - Heroku Error Code H10, after importing Postgres database from development environment

I created a Rails 3.2.13 app in the development environment, and as I pushed to Heroku to the production environment I got an error. I transferred my local development PostgreSQL database over to the ...
3
votes
1answer
195 views

how to query json data in text field rails postgresql

I have a database table column(collection) with data type text I have inserted json data in collection This is my json data {"name":"test","age":"25","country":"xxx"} But now how do i query this ...
0
votes
1answer
37 views

render query count(DISTINCT “reviews”.id) as my_count even if count result is 0

In a query below rails counts how many reviews and comments publication have and order results in a DESC order. For instance: publication one: 2 reviews + 10 comments = 12(my_count) publication ...
1
vote
0answers
86 views

postgres error role and db doesnt exist after downloading OSX Mavericks

I restarted my computer recently and after trying to start my db locally with rails s I got the following: ...
0
votes
1answer
49 views

Generate unique id for a new item in models on Rails 3

I populate book items into my Book model, But I found there are many items have the same id. So, how to create unique id for items. To prevent many items from having the same id ? Here is the book ...
0
votes
0answers
37 views

Rails update_all with hstore

What's a good way to update multiple records with hstore columns using activerecord? Right now I'm looping through, updating and saving like this: time = Time.now.to_s scoped_tasks.each do |task| ...
1
vote
1answer
29 views

Print and Email Images

How to print and email images in ruby-on-rails-3? My code is here: <%= image_tag('logo.png', :height => "100px",:width => "200px",:alt => "Software") %> It is not displaying the ...
0
votes
0answers
54 views

Rails 3 Postgres: sum column only on most recent record for a has_many relation

I have an School model that has_many Enrollment records. Each Enrollment record has a total column for the number of students. We update the enrollment amounts periodically, but I want to show the ...
0
votes
0answers
40 views

“Internal error” thrown by Rails to SQL conversion for query

Rails is throwing in "INTERNAL ERROR" when I try to run a particular query, does anyone have an idea how to resolve this? XYZ and ALongString are obfuscations since this is related to my work. ...
0
votes
0answers
57 views

How to sort objects by sum of values from other table

I've got Rails application with PostgreSQL database. There are Shop and Auction classes. Shop has many Auctions and Auction belongs to Shop. Auction has field 'views'. I want to order shops by sum of ...
0
votes
0answers
75 views

Converting postgresql extract epoch and greatest commands in query to rails 3

I have a working query in sql but I need to write it to Rails 3. Query looks something like this: SELECT sum((extract (EPOCH FROM end_time) - EXTRACT (EPOCH FROM start_time) - GREATEST(extract ...
2
votes
0answers
71 views

Rails background worker seems to be wrapped in a transaction

I know how useless and vague the title is. Sorry. I don't have much other than some observation and evidence that nothing changed in my code. I have a Rails 3.2.14 app using DelayedJob and PostgreSQL ...
0
votes
1answer
13 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
0answers
33 views

Rails, PostgreSQL and localtime

Is this expected behavior? When I query an activerecord object, the dates are on the correct timezone, in my case: User.select("current_sign_in_at").first :current_sign_in_at => Tue, 27 Aug 2013 ...
1
vote
1answer
62 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
0answers
37 views

Postgres searching domains with prefixes and english dictionary

I am using Postgres search through the Ruby gem pg_search. One of the columns I'm searching against contains domain names, such as "amazon.com", using a simple dictionary and prefixes I get the ...
0
votes
0answers
56 views

RoR Application built using spree works fine in local not in heroku

I have an ROR application thats about an year old so it uses older versions of multiple spree dependencies but i have ensured that it works perfectly and as expected without any dependency issues in ...
1
vote
0answers
37 views

Data not saved with attr_encryptor

I would like to encrypt data in my project so I use https://github.com/danpal/attr_encryptor I use this gem like this for my User model for example : attr_accessible :name, :mail attr_accessor :name ...
0
votes
0answers
133 views

Rails PG::Error: ERROR: value “214524245325432453” is out of range for type integer

This error is is triggered by PG before any validations like "greater_than". How can I handle this the Rails way and not in the controller?
2
votes
0answers
234 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 ...
1
vote
0answers
62 views

Validation creating error during postgresql migration

I'm migrating an app from rails 2.3 to rails 3. I'm planning on moving to heroku, so I'm also moving to postgres. I have a model which has lots of fields - about 30. I want to validate the ...
0
votes
0answers
52 views

Rails code working with sqlite but fails on heroku with postgres

Can any one suggest why the following query might be raising error: TypeError: can't dump anonymous class Class: INSERT INTO "emails" ("content", "created_at", "email_from", "email_to", "filter_id", ...
0
votes
0answers
40 views

Storing rails code in database. Upgraded from Rails 2 to Rails 3

I have the following piece of code illustrated as below. Was working in my Rails 2 application but having upgraded to Rails 3 it not longer works. When I render this code, I'm getting like, ...
0
votes
0answers
274 views

Using Sqlite3 test database and Postgres dev/production database in Rails

I currently have a rails project which I deploy to a production server which uses a postgres database. I develop my rails project in Windows, which means that if I want to test locally, I have to ...
0
votes
0answers
56 views

update query not updating in postgresql

Not updating postgresql database when update_all using @change_stat = Notification.where("fb_id = ? AND active = ?",@current_user.fb_id,true) @change_stat.update_all(:active => false)
0
votes
0answers
51 views

Going .pluck crazy. What is a realistic limit on query with array

I've used .pluck(:id) quite often (and map before it) to get a set of record ids. This is usually to get a set of related model records (e.g,, :people has_many :scores, as :assessed) Lets say I have ...
0
votes
2answers
55 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: ...
1
vote
0answers
38 views

Rails 3 Saving User Searches DataModel

I am working on a piece of my app where the client is wanting the ability for user searches to be saved (these searches are completed by the user completing a set of dropdowns and then entering in a ...
0
votes
0answers
65 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
29 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 ...
1
vote
0answers
250 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
163 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
124 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
201 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
2k 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
126 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
125 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
318 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 ...
1
vote
1answer
129 views

Custom collation for postgres adapter on Rails 3

On Postgres Collate and Ctype options are supported when creating database. I need to set ones when rails is creating database, but it seems there's no option for this in database.yml in Rails 3 ...
0
votes
1answer
304 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
239 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
131 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
137 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
377 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
225 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: ...
4
votes
1answer
308 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 ...

15 30 50 per page