Hi- Can this be done? When I destroy the master, I get an SQL error: ActiveRecord::StatementInvalid (Mysql::Error: Unknown column ''id'' in ''where clause'': DELETE FROM `votes` WHERE `id` = NULL ): This is because I have no ''ID'' in this table. So, how, in general do you automatically remove join records if there is no id in the join table? Thanks, Dino --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
if it can''t find them to destroy them, then how does a normal find work if you want to show them. anyway, you can define those sql-fragments with the associations: :finder_sql - overwrite the default generated SQL statement used to fetch the association with a manual statement :delete_sql - overwrite the default generated SQL statement used to remove links between the associated classes with a manual statement :insert_sql - overwrite the default generated SQL statement used to add links between the associated classes with a manual statement (not all of them exist for all association types) if that''s not possible you can execute pure sql. but that should be only necessary, if you''re forced to use some external db. -- 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 -~----------~----~----~----~------~----~------~--~---
dino d. wrote:> This is because I have no ''ID'' in this table. > > So, how, in general do you automatically remove join records if there > is no id in the join table? >look at has_many whatevers :dependent => :destroy within the rails api hth ilan -- 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 -~----------~----~----~----~------~----~------~--~---