This commit is contained in:
nwb 2014-07-16 15:52:52 +08:00
commit 1f5d792783
3 changed files with 24 additions and 20 deletions

View File

@ -50,14 +50,14 @@ class ForumsController < ApplicationController
def index
@offset, @limit = api_offset_and_limit({:limit => 10})
@forums_all = Forum.all
@forums_all = Forum.where('1=1')
@forums_count = @forums_all.count
@forums_pages = Paginator.new @forums_count, @limit, params['page']
@offset ||= @forums_pages.offset
# @forums = @forums_all.offset(@offset).limit(@limit).all
@forums = Forum.all
@forums = @forums_all.offset(@offset).limit(@limit).all
#@forums = Forum.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @forums }

View File

@ -32,25 +32,29 @@ class WelcomeController < ApplicationController
@projects_all = Project.active.visible.
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").
where("#{Project.table_name}.project_type = ? and #{Project.table_name}.id in (?)", Project::ProjectType_project,@hot_projects_ids)
if @first_page.nil? || @first_page.sort_type.nil?
@projects = @projects_all.order("grade desc")
else
case @first_page.sort_type
when 0
@projects = @projects_all.order("created_on desc")
when 1
@projects = @projects_all.order("grade desc")
when 2
@projects = @projects_all.order("watchers_count desc")
case @first_page.sort_type
when 0
@projects = @projects_all.order("created_on desc")
when 1
@projects = @projects_all.order("grade desc")
when 2
@projects = @projects_all.order("watchers_count desc")
#gcm
#when '3'
#gcm
#when '3'
#@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array)
# @projects=handle_project @projects_all,@project_activity_count
# @s_type = 3
# @projects = @projects[@project_pages.offset, @project_pages.per_page]
# @projects=handle_project @projects_all,@project_activity_count
# @s_type = 3
# @projects = @projects[@project_pages.offset, @project_pages.per_page]
else
@projects = @projects_all.order("grade desc")
else
@projects = @projects_all.order("grade desc")
end
end
end
def robots

View File

@ -1,6 +1,6 @@
class FirstPage < ActiveRecord::Base
attr_accessible :description, :title, :web_title,:page_type
validates_presence_of :web_title, :title, :description,:page_type,:sort_type
attr_accessible :description, :title, :web_title,:page_type,:sort_type
validates_presence_of :web_title, :title, :description,:page_type
validates_length_of :web_title,:title, maximum: 30
validates_length_of :description, maximum: 100
end