class Task < ActiveRecord::Base
belongs_to :court
has_many :workflow_tasks
has_many :task_users, :dependent => :destroy
has_many :court_users, :through => :task_users
has_many :users, :through => :court_users
end
class CourtUser < ActiveRecord::Base
belongs_to :court
belongs_to :user
end
I accessed the users as follows:
task.users.collect{|user|user.name}.join('','') unless
task.users.blank?
Following error thrown:
Mysql::Error: #42S22Unknown column ''court_users.task_id'' in
''where
clause'': SELECT users.* FROM users INNER JOIN court_users ON users.id
court_users.user_id WHERE ((court_users.task_id = 3))
Anyone knows the issue?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On Dec 4, 2007 2:02 AM, Ayyanar Aswathaman <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > class Task < ActiveRecord::Base > belongs_to :court > has_many :workflow_tasks > has_many :task_users, :dependent => :destroy > has_many :court_users, :through => :task_users > has_many :users, :through => :court_users > end > > class CourtUser < ActiveRecord::Base > belongs_to :court > belongs_to :user > end > > I accessed the users as follows: > > task.users.collect{|user|user.name}.join('','') unless task.users.blank? > > Following error thrown: > > Mysql::Error: #42S22Unknown column ''court_users.task_id'' in ''where > clause'': SELECT users.* FROM users INNER JOIN court_users ON users.id > court_users.user_id WHERE ((court_users.task_id = 3)) > > Anyone knows the issue?I''m guessing your court_users table doesn''t have a task_id column. -- Greg Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ayyanar Aswathaman wrote:> class Task < ActiveRecord::Base > belongs_to :court > has_many :workflow_tasks > has_many :task_users, :dependent => :destroy > has_many :court_users, :through => :task_users > has_many :users, :through => :court_users > end > ... > Anyone knows the issue?You can''t go through a through. You can only go through a regular has_many. -- Josh Susser http://blog.hasmanythrough.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---