Tagged Questions
0
votes
0answers
11 views
Exporting database data analysis to excel
I would like to create an export button or rake task for analyzing my database. I am using Rails 4, postgresql, and ActiveAdmin http://www.activeadmin.info/docs/4-csv-format.html. ActiveAdmin exports ...
0
votes
0answers
26 views
Rails Query for models that contain both/multiple associations
I have model Book and Books has_many Authors. I would like to find all the books that have associations with two different authors. The relationship is HABTM.
To find the number of books with one ...
0
votes
0answers
15 views
Why is Capistrano failing deploy with Ident authentication failed for user “postgres”
I have setup a Capistrano deploy in my site and I am trying to deploy to a staging server. The server is a CentoOS 6 server with nginx and passenger running through with it.
Everything runs okay ...
0
votes
0answers
31 views
Reload on user-object reverts changes made on its array field in db
I have an User model which has an array of roles.
From my schema.db:
create_table "users", force: true do |t|
t.string "roles", array: true
My model looks like this:
class User < ...
0
votes
1answer
21 views
Rails 4.0.5 - Handling params with arrays containing empty strings
Since I switched to Rails 4.0.5, some undesired behavior began occurring with a form for a model that uses a postgresql string array.
def up
add_column :cuts, :states, :text, :array => true
...
0
votes
0answers
43 views
Adding Postgresql to rails app
I am running Mac OSX 10.9.4, rails 4
I am trying to add Postgresql to a rails app to deploy to heroku. However, I cannot seem to bundle install it. And when i tried:
rails new myapp -d postgresql
...
1
vote
1answer
13 views
Postgres, Rails 4, Heroku - group by one column but select all columns
This question is possibly a duplicate but after reading through various answers to the similar questions and I have yet to create a working solution.
I have the model Post in rails 4. We can imagine ...
0
votes
0answers
22 views
Adding Username login to Devise in Rails 4 - Error creating User
Login works fine after following this guide: Allow users to sign in using their username or email address
However creating a new User does no longer work. This is what I am getting:
Started POST ...
0
votes
0answers
12 views
Different database for my application's tables and RefineryCMS's?
I'm starting a RefineryCMS project for the first time after being over fed up with Wordpress, and having created several application in Rails.
However the deployment process is somewhat confusing for ...
1
vote
0answers
24 views
Rails .update fails - id is uknown attribute?
This error has me baffled. Here's the controller code (not the Estimates controller)
...
@estimate = Estimate.find_by_link(params[:link])
...
if @estimate.customer_id.nil?
...
1
vote
2answers
51 views
SQL - where queries on join table
I'm trying to query a table, listings, based on a has_many relationship with listing_options. Listing options have different types and I'd like to make a SQL query that can match listings with ...
0
votes
0answers
17 views
How to force models(tables) cached in memory
I use Active Record to analysis data, which is not related to website.
I have 3 tables to do millions of queries SELECT but not update or insert.
So I want to cache all the tables in the memory to ...
0
votes
1answer
40 views
Gem install pg works but bundle install fails
There is very lot of topics about this but I already try almost all of them with no success.
I'm on Mac OS X 10.9.4 Mavericks, I have the Postgres.app, and it seams to work fine, sudo gem install pg ...
1
vote
1answer
16 views
Rails Postgresql Database Query for relationship name
I have a recipe which has many ingredients. An ingredient has many tastes. I would like to get all of the Recipes that do not have ingredients that have a certain taste.
One query would be for all ...
-1
votes
1answer
24 views
Optimizing my postgres database which holds over 500k restaurant information
I have a database of all the New York City restaurant inspection data. Currently there are ~520,000 entries and clearly they are not all unique. (i.e. restaurants appear more than once since they have ...
0
votes
2answers
16 views
I have an article “state” managed by a boolean field, but how can I get the first date (timestamp) when the checkbox was saved as published?
I hope this isn't just a friday brainfart, but here are more details:
I have an article model that only shows to the public when each article is marked as "published" and saved. However, the only ...
0
votes
2answers
16 views
Store info about current_user in constants to avoid unnecessary db hits - rails
I have many methods that get info about the current user, such as:
current_user.is_admin?
current_user.is_student?
current_user.is_teacher?
These methods need to evaluate if the current_user ...
0
votes
0answers
18 views
How to save the polygon coordinates in spatial db and find if the position is within the polygon in rails?
I have a google map with drawing tools enabled and I wanted to save the polygon coordinates in spatial db and find if the position of the object(user) is within the polygon area.
How can i save the ...
1
vote
1answer
21 views
How can I import data from ASCII (ISO/IEC 8859-1) to my Rails/PGSQL database?
I am trying to use data from the USDA found here: http://www.ars.usda.gov/Services/docs.htm?docid=23634
ASCII (8.6Mb) - This file contains the SR26 data in ASCII (ISO/IEC 8859-1), delimited files. ...
0
votes
0answers
20 views
Rails Create has_many_through won't create records
I am creating an exercise tracking website that has a Workout table, a WorkoutExercise table, and an Exercise table (this is just some of the schema).
I have been trying to create a "WorkoutExercise" ...
-3
votes
0answers
19 views
How I can retrieve decimal value with all zeros from postgresql sb
In my rails project I need to retrieve the value with all decimal zeros. I use rails 4.1 and postgresql. The column in question is type decimal precision:8, scale: 2. I can't use any number helper ...
0
votes
0answers
15 views
Unable to migrate database in AWS using capistrano
I am newbie to rails as well as deployment into production (AWS) using capistrano.
Its more than a day finding about this error and trying all the suggestions from SO and nothing is working out for ...
0
votes
1answer
21 views
Unable to run more than one spec scenario
I got problem with my Capybara spec. The thing is when I run spec with more than one scenario it crashes - commenting any of this two scenarios makes test passing. Error says that there cannot be ...
0
votes
1answer
23 views
How to handle multiple models using PaperClip?
I am building an app built on top of Active Admin. The idea is to have a backend I can control and update/edit using a CMS like interface. From there, I am building an API on the data I am controlling ...
0
votes
1answer
38 views
Eager loading with polymorphic associations
I have three models:
User.rb
belongs_to :profile, polymorphic: true
Customer.rb
has_one :user, as: :profile, dependent: :destroy
Sale.rb
belongs_to :customer
I want to pull all the sales with the ...
0
votes
0answers
14 views
Rails: Query and joins on postgres schemas
Using postgresql schema's pretty heavily and want to convert many of my previously sql written queries to ActiveRecord query.
Firstly, how would I convert a query like this to AR:
def language
...
0
votes
0answers
28 views
Rails 4: Database Entry is empty and exists
First, the Problem:
Started POST "/weapons" for 127.0.0.1 at 2014-07-06 00:13:15 +0200
Processing by WeaponsController#create as HTML
Parameters: {"utf8"=>"✓", ...
1
vote
2answers
19 views
Refactor a query with two subselects in WHERE
I've got the following scope on the Project model to find projects to which at least 80 crowdfunding pledges have been done or projects which have reached their goal already:
class Project < ...
1
vote
1answer
49 views
Search result ordering by precedence in rails
I am searching against title and description of Products. it works cool but all i need a search like to get a result precedence based. like in result products with title match comes first then ...
0
votes
0answers
12 views
Complex PSQL, Rails, and Geocoder
I have
class Address < ActiveRecord::Base
belongs_to :addressable, polymorphic: true
end
class Product < ActiveRecord::Base
belongs_to :product_reference
belongs_to :owner, polymorphic: ...
0
votes
0answers
28 views
Postgres on local machine: rake db:migrate produces an error
I am adding an application to a new OSX machine (10.9.3 with RVM and Ruby 2.1.1). I am using postgresapp, like in the rest of my work environments, but here I am getting an error when I try to migrate ...
1
vote
4answers
34 views
How to write this ActiveRecord Query using Join instead of subquery in Rails 4
Consider the following:
class User < ActiveRecord::Base
has_many :events
end
class Event < ActiveRecord::Base
belongs_to :user #this user is the event owner
has_many :members
end
class ...
0
votes
2answers
49 views
Rails: database queries too slow for scope that depends on join with another table
I'm building a Rails 4.1 app (using Postgres as my database) which has a couple of models set up in the following manner:
class Components < ActiveRecord::Base
has_many :compositions
scope ...
0
votes
3answers
42 views
How to concatenate string fields to one field with a delimiter in rails 4 application?
I have multiple checkboxes in form, in which I store the results of every field in their corresponding temporary fields which I specified in model with attr_accessor: attribute. I want to join the ...
0
votes
0answers
15 views
impossible to push on heroku because I get an error with pg
I can not get a push on heroku my project ruby on rails 4 for a moment he said:
Gem :: LoadError: Specified 'postgresql' for database adapt, the goal is not loaded gem. Add gem 'pg' to your ...
1
vote
1answer
24 views
Rails ActiveRecord polymorphic associated relationships
I've made a Rails app where I have tags, which I can use to tag various other models, however unlike a normal polymorphic relationship there is only 1 tag record for each tag name and then I used a ...
0
votes
0answers
41 views
using pg_search in rails 4 with a scoped association
Edit: Reading more about full text search in Postgres, I think I'm trying to push the gem past what it's designed for. Multi-table searches in postgres aren't going to be performant even if I get the ...
0
votes
2answers
43 views
PostgreSQL - must appear in the GROUP BY clause or be used in an aggregate function
This query works locally, but doesn't work on Heroku for some reason.
2014-06-26T00:45:11.334388+00:00 app[web.1]: PG::GroupingError: ERROR: column
"conversations.updated_at" must appear in the ...
0
votes
1answer
45 views
Rails model user ID PG ERROR: NotNullViolation
I'm using rails 4, postgres 9.3 and devise, and at the moment of sign up an user, I'm getting the error of :
PG::NotNullViolation: ERROR: the null value for column « usuario_id » violates the ...
0
votes
0answers
28 views
Database encryption options for Ruby on Rails hosted on Heroku
One of the clients I'm working with is requesting that I encrypt my database. The problem is, none of my other clients need or care about this.
I am wondering two things:
How costly (performance) ...
0
votes
1answer
36 views
Selecting Positive/Negative Values of a computation SQL
I have a User model and a Workplace model. User has a field gender(m/f) and each workplace has many users. I want to select the count of total number of users in a workplace and also the count of ...
2
votes
2answers
29 views
Selecting Multiple Counts from the database
I have a User model and a Workplace model.
User has a field gender(m/f) and each workplace has many users.
I want to select the count of total number of users in a workplace and also the count of ...
0
votes
1answer
51 views
ActiveRecord Postgres adapter generating invalid SQL WHERE clause: WHERE(“fieldname”)
ActiveRecord 4.1.1 is generating some peculiar SQL on save that postgres is choking on:
SELECT "projects".* FROM "projects" WHERE ('uid') LIMIT 1
PG::InvalidTextRepresentation: ERROR: invalid ...
1
vote
1answer
24 views
Heroku nil class error
I just pushed my local Rails 4 app to Heroku, and I've got a strange error. As is often the case, it works fine locally with no issues. I think that the Heroku DB / environment is basically the same ...
2
votes
0answers
54 views
will_paginate, Rails 4.1.1 pg error with count
I receive this error:
Completed 500 Internal Server Error in 73ms
2014-06-24T16:23:01.334241+00:00 app[web.1]: Processing by CollectionsController#index as HTML
2014-06-24T16:23:01.409751+00:00 ...
1
vote
1answer
52 views
Postgresql JSON column as HashWithIndifferentAccess
I have a table called 'my_models' with a 'json' column called 'settings'.
I also have the following model:
class MyModels < ActiveRecord::Base
end
The 'settings' attribute of an 'MyModels' ...
0
votes
1answer
64 views
How to group/select JSON type column (PG::UndefinedFunction: ERROR: could not identify an equality operator for type json)
I wanna do
<MODEL>.select("brief_content").group("brief_content")
Here's the table scheme ,
:id => :integer,
:content => :json,
:brief_content => ...
0
votes
0answers
38 views
Rails Activerecord Relation: using subquery as a table for a SQL select statement
Can somebody help me figure out how to write the following SQL using Rails (I'm using Rails 4) Activerecord methods? I know you can do this with find_by_sql but I'd like to preserve the active record ...
2
votes
0answers
24 views
Carrierwave mounted to Rails 4 PostgreSQL array attribute
Since Rails >= 4.0 adds support for PostgreSQL array data types I was wondering if anyone already played with carrierwave attachments mounted to array attributes instead of join tables when a model ...
0
votes
0answers
96 views
PG Error could not connect to server: Connection refused Is the server running on port 5432?
I recently updated my machine (MacBook Pro running Mountain Lion) and ever since then, whenever I set up a rails project, my machine craps out and cannot connect to PG. Currently, this is the error I ...