diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 3b8b4b928..9c41f91d6 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -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 } diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 48c0cf1fb..6a1772c8b 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -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 diff --git a/app/models/first_page.rb b/app/models/first_page.rb index d1fca531e..52c6e204d 100644 --- a/app/models/first_page.rb +++ b/app/models/first_page.rb @@ -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