[Rails] Re: referential integrity
On Apr 13, 11:06 pm, doughie eamonn.fahe...@gmail.com wrote: question 1) should there be foreign key relations in mysql db? I used the script/generate model and then rake db:migrate Rails has no native support for foreign key constraints in the DB. I use the RedHillOnRails Core plugin, unfortunately there main site went offline not long ago but you can get the plugin from: http://github.com/harukizaemon/redhillonrails_core/tree/master. This allows you to specify foreign keys in migrations if you want the database to maintain referential integrity for you (dunno who wouldn't!). question 2) in my conceptual model my developer belongs to a team. So i have the model above. Should there be a relationship in team describing how the link exists to developer? Currently mine is empty: class Team ActiveRecord::Base end You would say has_many :developers. The Rails API ActiveRecord::Associations documentation provides an in-depth discussion of relations. Best regards, Andrew --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: referential integrity
Your Team has many members and should be noted: class Team ActiveRecord::Base has_many :members end This is assuming that you have a column in your member table named team_id. I think this is what you were asking about with the foreign keys. As a somewhat noob to Rails myself I found a few good books for beginners to be the most help. The two I like the best are: Simply Rails 2 and Agile Web Development with Rails. On Apr 13, 7:43 pm, Andrew France andrew+li...@avito.co.uk wrote: On Apr 13, 11:06 pm, doughie eamonn.fahe...@gmail.com wrote: question 1) should there be foreign key relations in mysql db? I used the script/generate model and then rake db:migrate Rails has no native support for foreign key constraints in the DB. I use the RedHillOnRails Core plugin, unfortunately there main site went offline not long ago but you can get the plugin from:http://github.com/harukizaemon/redhillonrails_core/tree/master. This allows you to specify foreign keys in migrations if you want the database to maintain referential integrity for you (dunno who wouldn't!). question 2) in my conceptual model my developer belongs to a team. So i have the model above. Should there be a relationship in team describing how the link exists to developer? Currently mine is empty: class Team ActiveRecord::Base end You would say has_many :developers. The Rails API ActiveRecord::Associations documentation provides an in-depth discussion of relations. Best regards, Andrew --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Referential integrity in Rails
On Oct 14, 6:26 pm, Marcos [EMAIL PROTECTED] wrote: However, as I get past the basic tutorials/demos, I have yet to see good examples of a more complex domain model. Could anyone point me to some good references/resources please? I'm not sure what level of complexity you're looking for, but one of the more well-known open source Rails projects that is at least a step or two above trivial examples is the Typo blog engine (http:// typosphere.org/projects/show/typo). Disclaimer - I've never looked at its code, and have no information on the quality of it whatsoever. Additionally, while not full-on projects themselves, there are very well-written Rails plugins that do set up structures for DB persistence (the OAuth Rails plugin and Authenticated System plugins come immediately to mind). Those might be a good starting point. --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---