Tagged Questions
0
votes
0answers
19 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 ...
1
vote
1answer
25 views
Get all the rows raleted with a specific string
I am using rails with a postgresql db, and I would like to know which is the best solution, in getting all the rows which are similar with a string.
string format: domain.com or domain.com/uk or ...
1
vote
2answers
33 views
RoR - Failed to installing pg on rails app
I'm trying to push a project to heroku....
I'm at the step where it say's: rails new myapp --database=postgresql
After I created the command: rails new heroku:
Gem::Installer::ExtensionBuildError: ...
0
votes
1answer
24 views
Rails table indexes are not foreign keys in database as expected - why?
I have created tables for user and attendance (Users, Attendances) and all is good. A user has many attendances and an attendance belongs to user. The code works and Rails works but there is one big ...
0
votes
2answers
30 views
Grouping by month in database and not with ruby
I'm trying to group calls by month but I need to do it in the database and not with ruby. Here is the current code:
Call.limit(1000).group_by { |t| t.created_at.month }
Which returns:
SELECT ...
1
vote
1answer
28 views
Find record whose date range includes a given date?
I have a list of pay periods in a database and need to find a record based on a given date.
For example, pay period #26 is for the date range October 13, 2013 through October 26, 2013.
If I passed ...
0
votes
0answers
27 views
Rails 4 polymorphic, self-join or ancestry?
I've got a Venue structure to create where you are able to place different types of components under different locations in the same Venue so the structures are like this:
Main Hall -> Conference ...
2
votes
2answers
85 views
+250
Rails 4 ActiveRecord throws PG::UnableToSend on Ubuntu 13.04
We have a Ruby v.2.0.0-p247 on Rails v4.0.1 application using pg gem v0.17.0.
The application runs smoothly under Mac OS X Mavericks v10.9 with PostgreSQL Server v9.2.4 installed using HomeBrew but ...
0
votes
0answers
20 views
Data distribution for a system with SOA
I have a rails application which manages different types of items and users who own them. Items of different types might have different features. There is a number of sinatra services which have to ...
0
votes
0answers
55 views
postgresql gem with ruby 2.0.0-p353 on mac wont suceed
I'm trying to bundle a new rails app using Postgres.
I get this error each time I try to bundle.
Errno::EACCES: Permission denied - /usr/local/var/rbenv/versions/2.0.0- ...
1
vote
1answer
31 views
Using interval in PostgreSQL with Ruby on Rails
I want to save durations (2 days, 5 years, ...) as intervals in PostgreSQL from my Rails application.
Both duration_min and duration_max are values like "2 days" or "5 years", so each of them is an ...
0
votes
0answers
51 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) ...
0
votes
1answer
31 views
Rails - Issue when running bundle install - Installing pg (0.17.0)
When running 'bundle install' I get the following error message.
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
...
0
votes
2answers
31 views
Plucking from an Associated Model
I have two models, User and Post. Post belongs to User. User has a field titled name. I want to pluck the names of users. I was thinking of doing something like this.
some_cool_posts = Post.limit(5)
...
1
vote
2answers
79 views
Ruby on rails - wrong number of arguments (2 for 1) [Rails]
I've just change my database from sqlite3 to postgresql in my Ruby on rails.
Every things worked before but now I have a "wrong number of arguments (2 for 1)" when I submit the form. I don't ...
0
votes
1answer
38 views
Rails lost migration file issue
2 months ago, one of my migration files has been removed. The thing is when I rake db:migrate my database in localhost the migration is missing. I can Not create a new migration because the production ...
1
vote
5answers
75 views
<% if current_user.id == @status.user_id %> when user not signed in
Currently, I have in my 'show' view for a question model
<% if current_user.id == @question.user_id %>
<%= link_to 'Edit', edit_question_path(@question) %>
<% else ...
0
votes
4answers
32 views
getting a random product in rails
/products/index.html.erb
<div class="hide-for-small panel">
<h3>Sidebar</h3>
<h5 class="subheader">Feature Product</h5>
<% Product.random do | product | %>
...
0
votes
2answers
36 views
Ruby on rails : Data base sqlite3 to PostgreSQL [RALS]
I'm converting my data base from sqlite3 to PostgreSQL in my rails project, so I follow this tutorial : https://devcenter.heroku.com/articles/sqlite3
I suceed to make all the needed changes but at ...
0
votes
2answers
46 views
Postgresql with Rails 4.0.1 — not running on localhost:3000 or deploying to Heroku
When I try to run my sample Rails 4.0.1 app on my localhost:3000, I get this error:
PG:: ConnectionsBad
FATAL: role "myapp" does not exist.
I'm running on Maverick OSX and using Ruby 2.0. I created ...
1
vote
2answers
36 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,
...
3
votes
1answer
28 views
Trying to set prices to extended decimal/BTC in Rails on Heroku
So I'm relatively new to Rails, but have been trying to build a little store to sell some things for bitcoin. When I run my storefront on my local environment my pricing looks great (i.e. a book for ...
-1
votes
0answers
30 views
Reverse engineering radio buttons with multiple options and its sub-values
I need to reverse engineer below field in Rails. I've tried various methods like saving into another string column then reference this from types table with belongs_to relationship. This doesn't seem ...
1
vote
1answer
24 views
Restore PG local database from SQLite DB - Rails
I just switched my whole app's (dev and test) databases to Postgres and got it working well. I did have a ton of information (users, posts, etc) on my local sqlite database that I would love to ...
0
votes
1answer
94 views
Rails 4 Hstore, array escaped quotes
I'm trying to store a Hash of arrays using Rails 4 and Hstore (Postgres 9.2) for when users submit a form with a bunch of checkboxes. The problem I'm having is that once they're stored, all the ...
0
votes
1answer
34 views
How to Conditionally Rollback a Transaction Using the PG Ruby Gem
I am currently taking a databases course and one of the lab questions has me stumped as to how to implement the above and indeed, if it was even possible. I have tried searching the docs but the ...
1
vote
1answer
24 views
How can I avoid duplication in a join query using Sequel with Postgres on Sinatra?
I want to do a simple join. I have two tables: "candidates" and "notes".
Not all candidates have notes written about them, some candidates have more than one note written about them. The linking ...
1
vote
0answers
46 views
gem install dm-postgres-adapter build error
i'm trying to build dm-postgres-adapter but get this error.
sudo gem install dm-postgres-adapter
Building native extensions. This could take a while...
ERROR: Error installing dm-postgres-adapter:
...
0
votes
1answer
58 views
Rake db:migrate and db:create not operated with proper database files
I know this question has come up on stackoverflow before, and I have tried the various solutions suggested, even trying to restart my current app. But none of them worked. I am trying to change my ...
0
votes
1answer
33 views
Postgres/Rails => is object guaranteed to be persisted if I do .save?
If I have a model and save it like this:
model = Website.new
model.attr = 1
model.id = 1
model.save #assume no errors in saving
then retrieve it like this:
model2 = Website.find(1)
Will model2 ...
0
votes
1answer
69 views
Adding or Subtracting Time From Postgres Timestamps
I am using the following ruby code, with the PG gem, to return a timestamp that is in Postgres "timestamp without timezone" format. Instead of returning the current value, I would like it to return ...
1
vote
1answer
55 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 ...
1
vote
1answer
40 views
Questions about Rails-Postgres Database connections
We have recently been having issues with postgres running out of connection slots, and after a lot of debugging and shrugging of shoulders we have pretty much tracked it down to the fact that we ...
2
votes
2answers
71 views
Rails validating values in array
In my Schedule model I want to add some validation to the :wdays field, which is an int[]. I only want values 0..6 to be valid
Valid
Schedule.wdays = [0,1,6]
Invalid
Schedule.wdays = [0,1,10]
I ...
0
votes
2answers
48 views
Removing Column Names From PG Gem Return Values
I am trying to retrieve a list of URLs from my Postgres DB, using the following method...
def get_urls(site_id)
conn = PGconn.open(:dbname => 'my_listings')
res = conn.exec("SELECT url_list ...
1
vote
2answers
34 views
psql could not connect
I am currently working on a ruby on rails application and I am having problems running a RSpec test. With further drilling , i went into my terminal and tried to run the simple psql command
psql
...
1
vote
2answers
480 views
bundle install errors at pg (0.16.0) on OS X 10.9
I am trying to install metasploit on OS X 10.9. Everything i run bundle install, at the installing pg (0.16.0) it errors out
...
0
votes
2answers
49 views
Read Lock in Ruby on Rails
There doesn't seem to be a built-in way to acquire a read lock in Rails (for a table). I know these are not typically ideal, but my use case seems to require one:
There are a limited number of ...
1
vote
4answers
82 views
Store the day of the week and time?
I have a two-part question about storing days of the week and time in a database. I'm using Rails 4.0, Ruby 2.0.0, and Postgres.
I have certain events, and those events have a schedule. For the event ...
0
votes
3answers
75 views
Sorting broken when moving to Postgresql
I'm deploying my application to heroku (and like a n00b) during my development I was using SQLite3. I deployed to Heroku and i'm getting errors for specific pages. I loaded up Postgresql as my ...
-1
votes
1answer
55 views
Why is the 'where' method making an unnecessary database call?
I am running Rails 3.2.10 on Ruby 1.9.3, use PostgreSQL as the db and RubyMine to debug my code. While debugging, I noticed that, this line:
@monkeys = Monkey.where(user_id: 2)
Makes 2 database ...
0
votes
2answers
43 views
Seeding with a has_many relationship
Im trying to seed my db with recipes that has a has_many relationship with ingredients. The ingredient table has 4 rows. I keep running into errors with my code however. Here's my code. I'm fairly new ...
0
votes
1answer
110 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
43 views
Unable to insert data including a timestamp with the PG gem?
I am using the PG gem to insert data into my Postgres database, however, when I try to insert data including a timestamp, the database does not get updated. Here is the code I ran from IRB:
:001 ...
1
vote
1answer
68 views
Find diseases from users suffering for a specific disease
EDITED:
I trying to get all other DISEASES from users suffering for disease A.
OLD QUESTION (WRONG):
I trying to get users suffering from some disease also suffer for other diseases:
class User
...
0
votes
1answer
51 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: ...
0
votes
1answer
35 views
What are different steps to optimize the postgres database and queries?
I am optimizing Postgres with Ruby on Rails . For last few days I am finding that my site is loading slowly. Application is using different queries with join of 3- 4 tables to fetch the data .
...
0
votes
1answer
67 views
postgres encoding error in sidekiq app
I am working on an application where a ruby sidekiq process calls a 3rd party and parses the data into a database.
I am using sequel ad my orm.
I am getting some weird characters back in the ...
3
votes
2answers
67 views
Wrong order on has_many association when upgrading from rails 3 to rails 4
I am trying to update one project from Rails 3 to Rails 4. In Rails 3 I was doing:
class Sale < ActiveRecord::Base
has_many :windows, :dependent => :destroy
has_many :tint_codes, :through ...
0
votes
2answers
38 views
Postgresql lock shared table with multiple users
So, I'm having a synchronization issue here; Let's explain the situation:
I have a table called Sendings, that consists of these columns:
id sending_object_id type destinatary
The id is the ...