load user in homework

This commit is contained in:
yanxd 2014-06-05 17:29:11 +08:00
parent 1c7923e5bd
commit 57994edc06
2 changed files with 2 additions and 2 deletions

View File

@ -410,7 +410,7 @@ class BidsController < ApplicationController
@homework = HomeworkAttach.new
#@homework_list = @bid.homeworks
#增加作业按评分排序,
@homework_list = @bid.homeworks.joins(:user).includes(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC')
@homework_list = @bid.homeworks.joins(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC')
if params[:student_id].present?
@temp = []
@homework_list.each do |pro|

View File

@ -179,7 +179,7 @@
<tr>
<td style="padding-top: 5px"> <% if @bid.homework_type == 1%>
<% if @bid.homeworks.size>0 %>
<% for homework in @bid.homeworks %>
<% for homework in @bid.homeworks.eager_load(:user) %>
<%= link_to image_tag(url_to_avatar(homework.user), :class => "avatar", :title => homework.user.name), user_path(homework.user), :class => "avatar" %> <% end %>
<% else %>
<p class="font_lighter">