0
votes
3answers
24 views

Able to add myself as friend in rails console

I have built a user and friend relationship model but the problem is that with those associations I can friend myself. I have successfully suppressed it in my views and controller, but logically it ...
0
votes
0answers
32 views

Count Consecutive Records matching a criteria in rails

I have a rails model called UserAttempt which has done_correct:boolean entry in database. The model has a method on it called delta_tts which returns a float value. ie., user_attempt.delta_tts = ...
0
votes
0answers
23 views

Heroku ClearDb Mysql database, record id increasing by 10 [duplicate]

I have a rails application which is deployed to heroku. Now i have installed ClearDB Mysql database addon on heroku as my application is using Mysql database. Issue: When I am creating a new user, ...
0
votes
0answers
107 views

How to convert mysql subquery in join to the activerecord query

I have following query which is giving the proper result but I am failed to convert it into active record query.Can anybody help me on this? Thanks in advance. SELECT * FROM `athlete_schools` join ( ...
0
votes
1answer
39 views

How to add a new attribute to Associate Table column in rails

In my rails application, I had to add a new column named is_leader for an association table. The relationship for the association table is as follows: has_and_belongs_to_many :analysis_responses, ...
0
votes
0answers
141 views

Rails 3 has_and_belongs_to_many join table conditions. Looking for a better solution

Please read the whole question. I have a solution I'm looking for a better one that's more "Rails 3". So. I have been scratching my head on this one. In the mean time I have a custom built query to ...
0
votes
2answers
78 views

Group Record by 15 minutes

I want to group the records by every 15 minutes based on the time stamp column using the below query, but the first two record difference in only 10 min. RAILS CODE: ...
0
votes
2answers
47 views

ActiveRecord find with composite join

Suppose I want to do SELECT persons.name, cars.registration FROM persons, cars WHERE persons.state=cars.state AND persons.state_id_number=cars.owner_id_number ; Hint: people in different states ...
1
vote
3answers
142 views

Date reverts to 2000-01-01 from ActiveRecord to MySQL

I am trying to save a time in a MySQL table. However, the date reverts to 2000-01-01. 1.9.2p320 :036 > vv = Visitor.new => #<Visitor id: nil, ip_address: nil, num_day_visits: nil, ...
0
votes
1answer
349 views

Can't delete record through Rails

I have a table, say Persons and if I do person = Person.find(:first) person.delete I get NoMethodError: undefined method `to_sym' for nil:NilClass from ...
0
votes
1answer
125 views

(auto-generated?) _ids gives ActiveRecord::UnknownPrimaryKey error

Suppose I have models class Widget < ActiveRecord::Base has_many :widget_spots and class WidgetSpot < ActiveRecord::Base belongs_to :widget Also, in my MySQL table 'widget_spots', I ...
0
votes
1answer
35 views

Rescuing all ConstraintException instead of shutdown

I'm facing a trouble with my application: I have a constraint on my database where trip_id + trip_level_id must be unique. Now, this is at database level (no validation), if I try to add an item with ...
0
votes
1answer
45 views

Intermittent MySql errors in rails

I intermittently get the following error on different tables. ActiveRecord::StatementInvalid (Mysql::Error: : INSERT INTO sessions (created_at, data, session_id, updated_at) VALUES (?, ?, ?, ...
1
vote
1answer
125 views

How to show previous data in same row using MySQL?

I'm having problem with showing data in my database. I have jos_stock table with field rem_balance. rem_balance have value 0, 126, 12, 9. In my website. rem_balance show it depends on the week i.e. ...
0
votes
1answer
59 views

Rails associations with lookup table that has a two column primary key

CD table looks something like this: cd.dogtag (primary key) ... cd_tracks has id and tracks (track name), example: 1 Turd On The Run cd_tracks2title is a lookup table to join many to many from ...

1 2 3 4 5 6
15 30 50 per page