Tagged Questions
0
votes
1answer
22 views
Rails handle multiple Params in search query
I have the following model and I want to pass multiple params in "with_query", don't know how to achieve it. currently you can see it takes only "query" param. how can I filter it with country and ...
0
votes
1answer
14 views
postgresql full text search rails title and description
I am trying to search a model with title and description, but having the following error. I want to be able to search title and description and the type of job. Any help will be really appreciated.
...
2
votes
1answer
39 views
Data type of attribute on join model in Active Record/Rails 3.2/PostgreSQL database
I have models Client and Sessions and a join model ClientSessionAssignment that associates the two. ClientSessionAssignment has one join column score which is defined as decimal type in schema.rb. I'm ...
1
vote
2answers
34 views
Active Record object based on group by count
Hi I am ROR developer and using rails 3.2.13 with Postgres database.
I have two models:
Question
attr_accessible :category, :is_active, :question_text, :question_type_id, :survey_id,
...
1
vote
1answer
27 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
26 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 ...
1
vote
1answer
47 views
DBI::OperationalError: could not connect to server: Connection refused
On rails console when I tried to connect to postgres database which on machine having ip address suppose xxx.xxx.xxx.xxx.
Gem installed
gem 'dbi'
sudo apt-get install libpq-dev
gem 'dbd-pg'
I ...
0
votes
1answer
75 views
Can't unfollow user because of Postgres
Rails 3.2, Twitter App
UPDATE: Sovled but any idea why it might work once, then when i try it again, I get Unknown key: #<User:0x007f9a5a946708> On line 16 users_controller.rb for @user. If i ...
0
votes
1answer
28 views
Schema.rb blank after transition to PostgreSQL
So after having a problem deploying to Heroku for the first time, I wanted to get my dev environment running Postgres..
That's when i couldn't get my dev environment working. My errors lie in the ...
0
votes
1answer
77 views
why there is difference between psql -version output and the psql version connected to my application?
I am building up a rails application that I cloned from my friend. I am using Ubuntu 13.10, rails 3.2.14. I am using a postgresql database and when I try to run rake db:migrate it gives me some error ...
0
votes
1answer
34 views
activerecord sql difficult query
I need to make a query with two options: first - select DISTINCT ON, secondly - order by (and order by other fields). BTW, having by don't work
At one sql forum I find a solution
WITH d AS (
SELECT ...
1
vote
2answers
41 views
rails 4 complex SQL scope
I have a model Users which has_many EventLogs.
I would like create a scope which will order Users by those with the most occurrences of EventLogs they have.
scope :highest_completed_events, .....
...
0
votes
1answer
49 views
How to find and replace data in a column via Rails migration
I have a column called "meta" in a table called "Notifications". The data in the column looks something like this:
---
:full_name: Dude
:user_id: 1
:update_id: 10
:update_type: want
:update_name: ...
1
vote
2answers
729 views
Postgres Configuration messed up after OSX Mavericks
After I installed Mavericks my postgres configuration seems completely messed up. I installed the dev tools for Maverick from xcode and I've tried putting host:localhost in the db yml but still if I ...
2
votes
0answers
70 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
28 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
66 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
59 views
SQL query for calculating percentage completion of a survey
Here I have a survey and survey has many questions.Question has many answers.This is very basic relation of my survey.Every question is having a 'sequence number'.This 'sequence number' is used for ...
0
votes
1answer
19 views
Storing array of floats in Postgres on Heroku
How would I go about doing this? Is it advisable?
I have a table called "Item" with columns "name" and "price".
Price changes all the time and I want to store all the changes so I can graph them.
I ...
1
vote
1answer
74 views
Rails: Calling .limit(5) changes order of results
I have a search function that basically runs an ordered list of model records. The problem is whenever I called .search.limit(5), the results are in a different order from when I call .search
Here is ...
0
votes
2answers
75 views
How can I present the postgres errors in a nice way?
I am new to Ruby on Rails, and this is my first project. I don't known really much, but I have a table that it has an unique index. For example, for User, the unique index is the e-mail, so I cannot ...
1
vote
1answer
58 views
ActiveAdmin and CircleCI: autoloader causes Postgres to fail
We are using ActiveAdmin and CircleCI with Postgres and Rails 3. It's been working fine, but after adding a new ActiveAdmin model, we get this during rake db:create db:schema:load:
...
1
vote
1answer
27 views
Heroku - Update db column each 1st of the month
In my app I have a Budget model with daily_avg column.
Also there are BudgetIncome and BudgetSpending models.
daily_avg = (BudgetIncome.sum(:debit) - ...
1
vote
1answer
69 views
How can I dump multiple postgres schemas using rake db:dump:schema
Our postgres database has two schemas: a public schema and a metadata schema. I need both schemas in my test database, but rake db:schema:dump only dumps the public schema. If I add ...
0
votes
1answer
105 views
Active Record Query - Search Multiple Columns for Multiple Strings and Return Only if They Are All Included
I need help designing a query via Active Record & Postgresql.
• The query must search across all of the following columns...
The Model looks like this:
Collection
item_id1: String
...
1
vote
2answers
76 views
ActiveRecord Query Failing For Name Containing Accented Characters
I have a Rails app using Postgres. I have a Document model that has a name attribute. Some names contain accented characters. A couple of example names:
Condições Para Aplicação Da Lei
...
0
votes
1answer
36 views
Select records based off of an associated records count
I have three models:
class Picture < ActiveRecord::Base
# fields: url
has_one :visit
end
class Visit < ActiveRecord::Base
# fields: total_visits
belongs_to :picture
end
class ...
1
vote
1answer
39 views
Ruby WHERE Clause - Listing Duplicate Objects(Postgresql)
I am working on determining the attitude of a post using AFINN 111, which can be found
here. Whenever one of these words are mentioned in the post, their corresponding values are selected and added, ...
3
votes
1answer
63 views
sums return String, only with postgresql
I am migrating a database from mysql to postgres. The migration itself was ok, following the postgres documentation.
Right now, I'm fixing our specific mysql queries.
In some point, we have now ...
0
votes
2answers
48 views
Rails model update doen't work after cap migrate
I have a Rails 3.2 application and I have some issues on the production side:
I have a model 'Poject' and did a migration to add a string for 'description'.
running
rake db:migrate
works fine on my ...
1
vote
2answers
269 views
Rails with postgres - activerecord query: sort by column ASC, then group by column
I have a model Laps, which belongs to :Car
So each car has many laps, but I need to do a query where i pull in the top 10 fastest Laps, but only pull in the fastest lap per each car. In other words, ...
0
votes
2answers
143 views
How to optimize/cache Rails query
I've Rails application where query takes way too long time. It uses postgresql DB and query consists of one table with thousands of records.
statistics_controller.rb
all_data = ...
0
votes
2answers
32 views
Rails shows rows from model, which aren't created
I have this part of code:
<% current_user.meta_accounts.each do |meta_account| %>
<%= content_tag(:li, link_to(meta_account.name, 'javascript:void(0)')) %>
<% end %>
So, I ...
1
vote
1answer
157 views
Ruby on Rails Tutorial Exercise 3.5
I am new to coding and stackoverflow.com. I have been following along ruby.railstutorial.org and was feeling pretty good when I tackled the advanced exercise in section 3.5 (replacing sqlite3 with pg ...
1
vote
2answers
60 views
Rails complaining attribute doesn't exist, but it works for other people
I should note before any of this, that my friend pulled from my git repo and it works perfectly for him.
The database has the attribute, and the attr_accessible is set. But Rails is throwing this ...
0
votes
1answer
211 views
RefineryCMS: app not running on Heroku
I did not add the --heroku option according to the guides/heroku. So I skipped to
2 Deploying an existing local Refinery application
And this is now my Gemfile
source 'https://rubygems.org'
gem ...
0
votes
1answer
28 views
Postgres error from active record joins
Rails 3.2 Refinery 2.0.10
I have a basic association between my engines where
Work
belongs_to client
Client
has_many works
In my controller I have a method that should give me a list of works ...
1
vote
2answers
38 views
Import PG Dump Into Sqlite3
So I have a PG dump and am wanting to import it into my sqlite3 db. What are some ways that I can go about this? I'm guessing that it might need to be converted to another format?
1
vote
2answers
75 views
Should I store US states as an array or create table columns?
I have an app that houses product data via a Product model and table. Each product has specific state availability (multiple states) that I will need to filter and/or search by in the future. I am ...
0
votes
3answers
81 views
grouping with a non-primary key in postgres / activerecord
I have a model Lap:
class Lap < ActiveRecord::Base
belongs_to :car
def self.by_carmodel(carmodel)
scoped = joins(:car_model).where(:car_models => {:name => carmodel})
scoped
...
2
votes
2answers
97 views
rails order by time with reversed 24 hour periods
I have a model which stores events which each have a start time.
The start time is handled by rails as Time, but stored in Postgres as datetime (I'm assuming) and rails just ignores the date and ...
1
vote
2answers
141 views
Convert rails mysql SQL to work with postresql
I have the following tags method which selects tags based on how many times they are used and then arrange them in that order. Code is based on the railscasts episode: ...
0
votes
2answers
77 views
running rails on guest linux virtualbox: a database.yml issue
a) I'm a ruby in rails beginner developer, and I use windows 7 machine as developement environment...
b) With VirtualBox I just installed, inside the Windows 7 "host", a Linux ubuntu sever "guest", ...
1
vote
1answer
105 views
Do rails Transactions blocks exit after all actions have been committed?
Related to Run rails code after an update to the database has commited, without after_commit, but I think deserving its own question.
If I have code like this:
my_instance = MyModel.find(1)
...
4
votes
2answers
135 views
Run rails code after an update to the database has commited, without after_commit
I'm trying to battle some race cases with my background task manager. Essentially, I have a Thing object (already exists) and assign it some properties, and then save it. After it is saved with the ...
1
vote
1answer
58 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 ...
-1
votes
1answer
169 views
ActiveRecord::RecordNotFound (Couldn't find all Songs with IDs (7, 9, 10, 18, 44, 46, 47, 55) (found 4 results, but was looking for 8)):
So, I had a friend help me get Omniauth-twitter working. However, now I've got serious issue. In order to get Omniauth working we had to change the primary_key on the users table to :uid instead of ...
1
vote
1answer
47 views
How can I write a down or reversible function in this migration?
So, in-case this migration causes any errors I'd like to be able to revert back/rake db:rollback.
The code:
class ChangeUidToPrimaryKey < ActiveRecord::Migration
def change
execute ALTER TABLE ...
0
votes
1answer
133 views
How do I write a Rails ActiveRecord scope that combines rows and returns only latest date amongst three dates?
I have a Rails application with a table like this:
id | parent_id | datetime_a | datetime_b | datetime_c
1 | 55 | 2013-08-03 11:00:00 | null | null
2 | 55 ...
1
vote
3answers
153 views
method in a model to match ALL association values
I have a model with a method where I am trying to "match all" tags a user selects. However, as soon as I select two tags in my app, and pass the params to the method below, it returns no results. One ...