Hello, I''m working on a legacy Rails project (they do exist already!) and I have some questions regarding foreign keys. Could someone point me to references on Rails and foreign keys? They don''t seem to be used or encouraged, but I don''t understand why. Can they be used and set up with migrations? (I know that can pose problems with the order of insertion but that can be solved in my case) How does Rails react when foreign keys give errors? Thanks for your help, Bart --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 8/29/06, Bart Braem <bart.braem-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m working on a legacy Rails project (they do exist already!) and I have > some questions regarding foreign keys. > Could someone point me to references on Rails and foreign keys? They don''t > seem to be used or encouraged, but I don''t understand why. > Can they be used and set up with migrations? (I know that can pose > problems > with the order of insertion but that can be solved in my case) > How does Rails react when foreign keys give errors?Many of us are using foreign key constraints in new apps as well. You can execute the code to manually add/drop them in your migrations or use one of the fk migrations plugins. When you violate a constraint, an ActiveRecord::StatementInvalid exception is raised. jeremy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I use http://www.agilewebdevelopment.com/plugins/foreign_key_schema_dumperall the time. It allows you to write the fkeys right into your migrations. Foreign keys can cause testing headaches, but googling ''rails foreign key testing'' or something similar brings up a lot of good info. On 8/29/06, Jeremy Kemper <jeremy-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> wrote:> > On 8/29/06, Bart Braem <bart.braem-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m working on a legacy Rails project (they do exist already!) and I > > have > > some questions regarding foreign keys. > > Could someone point me to references on Rails and foreign keys? They > > don''t > > seem to be used or encouraged, but I don''t understand why. > > Can they be used and set up with migrations? (I know that can pose > > problems > > with the order of insertion but that can be solved in my case) > > How does Rails react when foreign keys give errors? > > > Many of us are using foreign key constraints in new apps as well. > > You can execute the code to manually add/drop them in your migrations or > use one of the fk migrations plugins. > > When you violate a constraint, an ActiveRecord::StatementInvalid exception > is raised. > > jeremy > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---