这些代码输出 2 个 sql 查询。
@trackings = Tracking.where(:target_user_id => current_user.id ).page(params[:page]).per(10)
@trackings_count = Tracking.where(:target_user_id => current_user.id ).count
为了减少它,我该如何编码?
像这样的东西?
@trackings = Tracking.where(:target_user_id => current_user.id )
@trackings_count = @trackings.count
@trackings = @trackings.page(params[:page]).per(10)