Merge branch 'cxt_course' into develop

This commit is contained in:
cxt 2016-04-15 15:45:54 +08:00
commit 9fdd229b2c
2 changed files with 14 additions and 5 deletions

View File

@ -65,9 +65,18 @@ class AdminController < ApplicationController
#精品课程下的全部课程 #精品课程下的全部课程
def excellent_all_courses def excellent_all_courses
@name = params[:name] name = params[:name]
@courses = Course.like(@name).order('created_at desc') @order = ""
@courses = paginateHelper @courses,30 if params[:order] == 'asc'
courses = Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) asc, c.id desc")
@order = params[:order]
elsif params[:order] == 'desc'
courses = Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) DESC, c.id desc")
@order = params[:order]
else
courses = Course.like(name).order('created_at desc')
end
@courses = paginateHelper courses,30
@page = (params['page'] || 1).to_i - 1 @page = (params['page'] || 1).to_i - 1
respond_to do |format| respond_to do |format|
format.html format.html

View File

@ -48,8 +48,8 @@
<th style="width: 50px;"> <th style="width: 50px;">
帖子数 帖子数
</th> </th>
<th style="width: 50px;"> <th style="width: 50px;" class = "<%= @order == 'desc' ? 'st_up' : (@order == 'asc' ? 'st_down' : '') %>">
动态数 <%=link_to '动态数', excellent_all_courses_path(:order=> @order == "desc" ? 'asc' : 'desc') %>
</th> </th>
<th style="width: 40px;"> <th style="width: 40px;">
</tr> </tr>