class Task < ActiveRecord::Base belongs_to :court has_many :workflow_tasks has_many :task_users, :dependent => :destroy has_many :court_users, :through => :task_users end class TaskUser < ActiveRecord::Base belongs_to :task belongs_to :court_user end I accessed the court_user as follows: task.task_users.collect{|task_user|task_user.court_user.user.name} Error: undefined method `court_user'' for #<TaskUser:0x60f4320> Anyone knows the solution. It only happens in the development mode. It seams the autoloading not working properly. If I find the TaskUser directly like following it will work, but this is not the right solution. task_users = TaskUser.find(:all, :conditions=>[''task_id=?'',task.id]) task_users.collect{|task_user|task_user.court_user.user.name} -- 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 -~----------~----~----~----~------~----~------~--~---
> undefined method `court_user'' for #<TaskUser:0x60f4320> > > Anyone knows the solution. It only happens in the development mode. It > seams the autoloading not working properly.do you ever require a class that could be autoloaded? that can fox autoloading. There was a thread about this recently here. Fred> > If I find the TaskUser directly like following it will work, but this is > not the right solution. > > task_users = TaskUser.find(:all, :conditions=>[''task_id=?'',task.id]) > task_users.collect{|task_user|task_user.court_user.user.name} > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:>> undefined method `court_user'' for #<TaskUser:0x60f4320> >> >> Anyone knows the solution. It only happens in the development mode. It >> seams the autoloading not working properly. > > do you ever require a class that could be autoloaded? that can fox > autoloading. There was a thread about this recently here. > > FredIam sorry, I couldn''t get your solution for this issue my friend -- 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 -~----------~----~----~----~------~----~------~--~---
Ayyanar Aswathaman wrote:> Frederick Cheung wrote: >>> undefined method `court_user'' for #<TaskUser:0x60f4320> >>> >>> Anyone knows the solution. It only happens in the development mode. It >>> seams the autoloading not working properly. >> >> do you ever require a class that could be autoloaded? that can fox >> autoloading. There was a thread about this recently here. >> >> Fred > > Iam sorry, I couldn''t get your solution for this issue my friendAnyone knows? -- 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 -~----------~----~----~----~------~----~------~--~---
court_user is not defined on TaskUser. On Dec 5, 2007 2:15 PM, Ayyanar Aswathaman <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Ayyanar Aswathaman wrote: > > Frederick Cheung wrote: > >>> undefined method `court_user'' for #<TaskUser:0x60f4320> > >>> > >>> Anyone knows the solution. It only happens in the development mode. It > >>> seams the autoloading not working properly. > >> > >> do you ever require a class that could be autoloaded? that can fox > >> autoloading. There was a thread about this recently here. > >> > >> Fred > > > > Iam sorry, I couldn''t get your solution for this issue my friend > > Anyone knows? > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
task_user belongs_to court_user Ryan. It is defined in the TaskUser -- 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 -~----------~----~----~----~------~----~------~--~---
Ahh yes, but is it defined the other way around? Does a CourtUser have any relationship defined to task_user inside court_user.rb? On Dec 5, 2007 2:23 PM, Ayyanar Aswathaman <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > > task_user belongs_to court_user Ryan. It is defined in the TaskUser > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
No. I will tell you the table structure: task_users =========task_id court_user_id court_users ==========court_id user_id users =====name password -- 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 -~----------~----~----~----~------~----~------~--~---
I''m telling you that you haven''t defined it inside the file app/models/court_user.rb! Please listen carefully, it stops me repeating myself. You need to either have a belongs_to :task_user or a has_one :task_user or.. a task_user method defined on CourtUser. Your table structure has nothing to do with this. On Dec 5, 2007 3:06 PM, Ayyanar Aswathaman <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > > No. I will tell you the table structure: > > task_users > =========> task_id > court_user_id > > court_users > ==========> court_id > user_id > > users > =====> name > password > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> I''m telling you that you haven''t defined it inside the file > app/models/court_user.rb! Please listen carefully, it stops me repeating > myself. > > You need to either have a belongs_to :task_user or a has_one :task_user > or.. > a task_user method defined on CourtUser. > > Your table structure has nothing to do with this. > > On Dec 5, 2007 3:06 PM, Ayyanar Aswathaman > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > >> court_users >> Posted via http://www.ruby-forum.com/. >> >> > >> > > > -- > Ryan BiggYeah, we have defined has_many :task_users in the court_user.rb. -- 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 -~----------~----~----~----~------~----~------~--~---
Still not working. I will try out and post the solution. Thanks Ryan -- 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 -~----------~----~----~----~------~----~------~--~---
The solution is simple: You have defined a has_many :task_users on court_user meaning that there is no task_user (note the lack of an S) method on court_user. Either you define it as has_one :task_user or reference it as task_users. On Dec 5, 2007 4:35 PM, Ayyanar Aswathaman <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Still not working. I will try out and post the solution. Thanks Ryan > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The required classes were not included in the task_user.rb. require ''court_user.rb''. I missed this somehow. Thanks all for your support. -- 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 -~----------~----~----~----~------~----~------~--~---
This is a shot in the dark since I''m really struggling in understanding how your tables work together, but instead of, "task.task_users.collect{|task_user| task_user.court_user.user.name}" how about, "task.task_users.collect{|task_user| task_user.court_users.user.name}" or this, "task.task_users.collect{|task_user|task_user.users.name}" On Dec 4, 3:21 am, Ayyanar Aswathaman <rails-mailing-l...@andreas- s.net> 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 > end > > class TaskUser < ActiveRecord::Base > belongs_to :task > belongs_to :court_user > end > > I accessed the court_user as follows: > > task.task_users.collect{|task_user|task_user.court_user.user.name} > > Error: > > undefined method `court_user'' for #<TaskUser:0x60f4320> > > Anyone knows the solution. It only happens in the development mode. It > seams the autoloading not working properly. > > If I find the TaskUser directly like following it will work, but this is > not the right solution. > > task_users = TaskUser.find(:all, :conditions=>[''task_id=?'',task.id]) > task_users.collect{|task_user|task_user.court_user.user.name} > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---