From 6c0decc4ea022a4a9176542741df2c05bd0a5ea6 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Thu, 5 Mar 2009 21:42:41 -0600 Subject: [PATCH] Railsisms Use some ActiveRecord convenience methods. --- app/controllers/cache_sweeping_helper.rb | 2 +- app/models/web.rb | 4 ++-- app/models/wiki.rb | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/cache_sweeping_helper.rb b/app/controllers/cache_sweeping_helper.rb index 249b2f77..cfeacd48 100644 --- a/app/controllers/cache_sweeping_helper.rb +++ b/app/controllers/cache_sweeping_helper.rb @@ -8,7 +8,7 @@ module CacheSweepingHelper end def expire_cached_summary_pages(web) - categories = WikiReference.find(:all, :conditions => "link_type = 'C'") + categories = WikiReference.all(:conditions => "link_type = 'C'") %w(recently_revised list).each do |action| expire_action :controller => 'wiki', :web => web.address, :action => action categories.each do |category| diff --git a/app/models/web.rb b/app/models/web.rb index 21348282..7024e155 100644 --- a/app/models/web.rb +++ b/app/models/web.rb @@ -32,11 +32,11 @@ class Web < ActiveRecord::Base end def page(name) - pages.find(:first, :conditions => ['name = ?', name]) + pages.first(:conditions => ['name = ?', name]) end def last_page - return Page.find(:first, :order => 'id desc', :conditions => ['web_id = ?', self.id]) + return Page.first(:order => 'id desc', :conditions => ['web_id = ?', self.id]) end def has_page?(name) diff --git a/app/models/wiki.rb b/app/models/wiki.rb index 35de15d5..dc58e222 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -43,7 +43,7 @@ class Wiki ApplicationController.logger.debug "Web '#{web_address}' not found" return nil else - page = web.pages.find(:first, :conditions => ['name = ?', page_name]) + page = web.pages.first(:conditions => ['name = ?', page_name]) ApplicationController.logger.debug "Page '#{page_name}' #{page.nil? ? 'not' : ''} found" return page end @@ -76,7 +76,7 @@ class Wiki end def system - @system ||= (System.find(:first) || System.create) + @system ||= (System.first() || System.create) end def setup? @@ -84,7 +84,7 @@ class Wiki end def webs - @webs ||= Web.find(:all).inject({}) { |webs, web| webs.merge(web.address => web) } + @webs ||= Web.all.inject({}) { |webs, web| webs.merge(web.address => web) } end def storage_path