"What are best practices when an object has a large amount of associations with other models and the view needs access to those related objects?"
using the :include statement. say we would have two models schedule and employee an employee has_many schedules somewhere in the controller: @employee = Employee.find(:all, params[:id]) do this instead: @employee = Employee.find(:all, params[:id], :include => [:schedules]) Then Rails will load employee and schedules in one go with a SQL JOIN. any line like @employe.schedules.each do |schedule| won't need to access the db anymore --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] 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 -~----------~----~----~----~------~----~------~--~---

