From e0a7e0fec760ba12c8067a37e10c96f1f05876e2 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 24 Jun 2026 04:13:16 +0200 Subject: Stage 1 complete: Rails 2.3.5 to Rails 3.2.22.5 upgrade - Converted plugins to gems (Gemfile) - Updated config structure (application.rb, boot.rb, environment.rb) - Converted routes to Rails 3 DSL - Converted named_scope to scope throughout models - Converted find(:all, :conditions) to where() chains - Fixed has_many :order to use ordering scope - Updated session store and secret token configuration - Fixed exception_notification middleware configuration - Patched Ruby 2.4 / Rails 3.2 incompatibilities: - Integer/Float duration arithmetic (ActiveSupport) - Arel visit_Integer for PostgreSQL adapter - create_database String/Integer coercion - ActionController consider_all_requests_local - Migrated taggings schema for acts-as-taggable-on - Replaced dynamic_form gem with custom form_error_messages helper - Fixed Rails 3 block helper syntax (form_for, form_tag, fields_for) - Fixed admin layout yield - Updated test suite for Rails 3 APIs --- app/controllers/admin_controller.rb | 38 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'app/controllers/admin_controller.rb') diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index f3cc221..18c4104 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -5,21 +5,15 @@ class AdminController < ApplicationController before_filter :login_required def index - @drafts = Node.all( - :limit => 50, - :order => "updated_at desc", - :conditions => ["draft_id IS NOT NULL"] - ) - @drafts_count = Node.count( - :conditions => ["draft_id IS NOT NULL"] - ) - @recent_changes = Node.all( - :limit => 50, - :order => "updated_at desc", - :conditions => [ - "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", Time.now, Time.now-14.days - ] - ) + @drafts = Node.where("draft_id IS NOT NULL") + .limit(50).order("updated_at desc") + + @drafts_count = Node.where("draft_id IS NOT NULL").count + + @recent_changes = Node.where( + "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", + Time.now, Time.now - 14.days + ).limit(50).order("updated_at desc") all_nodes = Node.root.self_and_descendants @sitemap_depth = {} @@ -28,16 +22,12 @@ class AdminController < ApplicationController end @sitemap = all_nodes.to_a.sort! { |node1,node2| node1.lft <=> node2.lft }.delete_if { |node| node.update? } - @mypages = Page.all( - :conditions => [ "user_id = ? or editor_id = ?", @current_user, @current_user] - ) - - @mynodes = Node.all( - :order => "updated_at desc", - :joins => :pages, - :conditions => [ "pages.user_id = ? or pages.editor_id = ?", @current_user, @current_user ] - ).uniq.first(50) + @mypages = Page.where("user_id = ? or editor_id = ?", @current_user, @current_user) + @mynodes = Node.joins(:pages) + .where("pages.user_id = ? or pages.editor_id = ?", @current_user, @current_user) + .order("updated_at desc") + .uniq.first(50) end def search -- cgit v1.3