Comments on: Dynamic Select Boxes (many to many) – Ruby on Rails http://pullmonkey.com/2008/08/05/dynamic-select-boxes-many-to-many-ruby-on-rails/ Sun, 30 Aug 2009 04:40:55 +0000 hourly 1 https://wordpress.org/?v=5.6 By: Hilman Zaky http://pullmonkey.com/2008/08/05/dynamic-select-boxes-many-to-many-ruby-on-rails/comment-page-1/#comment-744 Tue, 05 Aug 2008 04:59:00 +0000 /2008/08/05/dynamic-select-boxes-many-to-many-ruby-on-rails#comment-744 Thanks Charlie
am I right if I said :
<filter:code attributes=lang="ruby">
class Artist < ActiveRecord::Base
has_many :artist_associations
has_many :genres, :through => :artist_associations
has_many :songs
end
< /filter:code>
codes means Artist has many Genres with artist_associations as a weak entity between Genres and Artists?
and is that "through" also mean dependent?

]]>
By: charlie http://pullmonkey.com/2008/08/05/dynamic-select-boxes-many-to-many-ruby-on-rails/comment-page-1/#comment-745 Tue, 05 Aug 2008 04:59:00 +0000 /2008/08/05/dynamic-select-boxes-many-to-many-ruby-on-rails#comment-745 @Hilman – artist_associations is a join table between genre and artist. And through does not mean dependent – I missed that in this example, but you bring up a good point. You will want to specify the :dependent => :destroy in the join table association, like this:<filter:code attributes=lang="ruby">has_many :artist_associations, :dependent => :destroy</filter:code> This will remove the association when an artist is deleted.

Hope this helps.

]]>
By: Hilman Zaky http://pullmonkey.com/2008/08/05/dynamic-select-boxes-many-to-many-ruby-on-rails/comment-page-1/#comment-746 Tue, 05 Aug 2008 04:59:00 +0000 /2008/08/05/dynamic-select-boxes-many-to-many-ruby-on-rails#comment-746 Okay.. once again thanks.. that’s helped me a lot..

]]>