Howdy, I have an app as follows: class Artist < ActiveRecord::Base has_and_belongs_to_many :releases has_many :ecards, :through => :releases end Ok... When I try this on the console: >> Artist.find(:first).ecards ActiveRecord::StatementInvalid: RuntimeError: ERROR C42703 Mcolumn releases.artist_id does not exist P96 Fparse_func.c L1058 Runknown_attribute: SELECT ecards.* FROM ecards INNER JOIN releases ON ecards.release_id = releases.id WHERE ((releases.artist_id = 80)) I did some searching and I didn''t see anything to indicate that :through wasn''t supported with habtm as a source. Am I doing something wrong? Any tips on getting this going? Thanks, Hunter --~--~---------~--~----~------------~-------~--~----~ 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 2/11/07, Hunter Hillegas <lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org> wrote:> > Howdy, > > I have an app as follows: > > class Artist < ActiveRecord::Base > has_and_belongs_to_many :releases > has_many :ecards, :through => :releases > end > > Ok... When I try this on the console: > > >> Artist.find(:first).ecards > ActiveRecord::StatementInvalid: RuntimeError: ERROR C42703 > Mcolumn releases.artist_id does not exist P96 > Fparse_func.c L1058 Runknown_attribute: SELECT ecards.* FROM > ecards INNER JOIN releases ON ecards.release_id = releases.id > WHERE ((releases.artist_id = 80)) > > I did some searching and I didn''t see anything to indicate > that :through wasn''t supported with habtm as a source. > > Am I doing something wrong? Any tips on getting this going? >I may be wrong but I''m pretty sure you just can'' do what you''re looking to do (not via any of the automated Rails macros, anyway). This may be one of those situations when Rails''s reluctance to do something for you is a sign that what you''re wanting to do isn''t such a great idea? Chad --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hunter Hillegas wrote:> Howdy, > > I have an app as follows: > > class Artist < ActiveRecord::Base > has_and_belongs_to_many :releases > has_many :ecards, :through => :releases > end > > Ok... When I try this on the console: > > >> Artist.find(:first).ecards > ActiveRecord::StatementInvalid: RuntimeError: ERROR C42703 > Mcolumn releases.artist_id does not exist P96 > Fparse_func.c L1058 Runknown_attribute: SELECT ecards.* FROM > ecards INNER JOIN releases ON ecards.release_id = releases.id > WHERE ((releases.artist_id = 80)) > > I did some searching and I didn''t see anything to indicate > that :through wasn''t supported with habtm as a source. > > Am I doing something wrong? Any tips on getting this going? > > Thanks, > Hunter >Maybe this is what you want instead? class Artist < ActiveRecord::Base has_many :releases has_many :ecards, :through => :releases end class Release < ActiveRecord::Base belongs_to :artist has_many :ecards end class Ecard < ActiveRecord::Base belongs_to :release end -- Chris Martin Web Developer http://chriscodes.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 -~----------~----~----~----~------~----~------~--~---