Hello, I have the following database structure: accounts account_jobs (account_id, job_id) jobs job_submissions (job_id, submission_id) submissions My Account model looks like this: - has_many :account_jobs - has_many :jobs, :through => :account_jobs I want to have all the job_submissions and submissions that belong to this account, WITH the ability to further search through them (example: Account.find(1).submissions.find(1) ). Thanks in advance, Rick -- 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 14 Apr 2008, at 12:33, Rick Rr wrote:> > Hello, > > I have the following database structure: > > accounts > account_jobs (account_id, job_id) > jobs > job_submissions (job_id, submission_id) > submissions > > My Account model looks like this: > - has_many :account_jobs > - has_many :jobs, :through => :account_jobs > > I want to have all the job_submissions and submissions that belong to > this account, WITH the ability to further search through them > (example: > Account.find(1).submissions.find(1) ). >don''t you just want to add has_many job_submissions & has_many submissions :through => job_submissions ? Fred> > Thanks in advance, > > Rick > -- > 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 -~----------~----~----~----~------~----~------~--~---
Hi Fred, No this is not the case, job_submissions doesn''t have a account_id key. Rick -- 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 -~----------~----~----~----~------~----~------~--~---
well it might be a good idea to add one, otherwise you will haver to do a JOIN over 5 tables ... with or without a rails-built-in way of doing that join, it''s not a very good thing, from a performance perspective. If those submissions always (in terms of logic) belong to to current user/account that is creating them, it''s a rather small change to add those account_id columns to the sub_submissions table, add the belongs_to and add the account in the create action of the job_submission. On 14 Apr., 13:55, Rick Rr <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi Fred, > > No this is not the case, job_submissions doesn''t have a account_id key. > > Rick > -- > 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 -~----------~----~----~----~------~----~------~--~---
Hello Thorsten, A job can be assigned to multiple accounts. Rick -- 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 -~----------~----~----~----~------~----~------~--~---
Rick, maybe this is what you''re looking for: http://agilewebdevelopment.com/plugins/nested_has_many_through Regards Philipp On Apr 14, 1:04 pm, Rick Rr <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello Thorsten, > > A job can be assigned to multiple accounts. > > Rick > -- > 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 -~----------~----~----~----~------~----~------~--~---