search for: teams_users

Displaying 3 results from an estimated 3 matches for "teams_users".

2006 Apr 03
2
HABTM migrations
Bad rails day for Matt- In a migration, for a habtm: create_table :teams_users do |t| t.column :team_id, :integer t.column :user_id, :integer end Ok, fine. In a controller (well really a migration script): @user.teams << Team.find( 3 ) And the SQL pumped at my server is: INSERT INTO teams_users (`team_id`, `id`, `user_id`) VALUES (...
2006 Sep 28
5
Eager loading using find_by_sql
...eager loading them all takes up too much time and memory. Inside my team model I have written the following function. <code> def find_users_and_notes_from_date(date) sql = "" sql += "SELECT distinct u.*, w.* " sql += "FROM whereusers u, wherenotes w, teams t, teams_users tu " sql += "WHERE u.id = tu.user_id " sql += "AND w.user_id = u.id " sql += "AND w.note_date = " + date.strftime(''\''%d-%b-%y\'''') + " " sql += "AND tu.team_id = " + self.id.to_s User.find_by_sql sql...
2006 Jul 26
8
team captain - habtm w/has_one...
the below... class User < ActiveRecord::Base has_and_belongs_to_many :teams class Team < ActiveRecord::Base has_and_belongs_to_many :users has_one :captain, :class_name => ''User'' produces the error... Mysql::Error: Unknown column ''users.team_id'' in ''where clause'': SELECT * FROM users WHERE (users.team_id = 1) LIMIT 1 i