I think you''ll find if you do
(eg.)
entry.keywords.delete(keyword)
(where ''entry'' and ''keyword'' are objects)
this will do what you want -
it deletes the join but not the actual keywords or entries.
Glenn
On Apr 3, 2005 4:15 AM, Miles Keaton
<mileskeaton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> On Apr 2, 2005 4:34 PM, Miles Keaton
<mileskeaton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > Given the info, below, how would you delete the entry_keyword_links
> > using ActiveRecord?
> >
> > I don''t want to delete the Keywords or the Entries. Just the
links
> > between them (for which there is no separate model - just the
> > has_and_belongs_to_many)
> >
> > Thanks!
> >
> > --
> >
> > class Entry < ActiveRecord::Base
> > has_and_belongs_to_many :keywords, :join_table =>
''entry_keyword_links''
> > end
> > class Keyword < ActiveRecord::Base
> > has_and_belongs_to_many :entries, :join_table =>
''entry_keyword_links''
> > end
> >
> > TABLE entry_keyword_links (
> > keyword_id int
> > entry_id int);
> >
>
> To be clear, I know I could do "DELETE FROM entry_keyword_links WHERE
> entry_id=#{id}" - but I''m wondering if there''s a
more ActiveRecord way
> to do this.
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>