Railsisms

Use some ActiveRecord convenience methods.
This commit is contained in:
Jacques Distler 2009-03-05 21:42:41 -06:00
parent 13d096c688
commit 6c0decc4ea
3 changed files with 6 additions and 6 deletions

View file

@ -8,7 +8,7 @@ module CacheSweepingHelper
end end
def expire_cached_summary_pages(web) 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| %w(recently_revised list).each do |action|
expire_action :controller => 'wiki', :web => web.address, :action => action expire_action :controller => 'wiki', :web => web.address, :action => action
categories.each do |category| categories.each do |category|

View file

@ -32,11 +32,11 @@ class Web < ActiveRecord::Base
end end
def page(name) def page(name)
pages.find(:first, :conditions => ['name = ?', name]) pages.first(:conditions => ['name = ?', name])
end end
def last_page 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 end
def has_page?(name) def has_page?(name)

View file

@ -43,7 +43,7 @@ class Wiki
ApplicationController.logger.debug "Web '#{web_address}' not found" ApplicationController.logger.debug "Web '#{web_address}' not found"
return nil return nil
else 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" ApplicationController.logger.debug "Page '#{page_name}' #{page.nil? ? 'not' : ''} found"
return page return page
end end
@ -76,7 +76,7 @@ class Wiki
end end
def system def system
@system ||= (System.find(:first) || System.create) @system ||= (System.first() || System.create)
end end
def setup? def setup?
@ -84,7 +84,7 @@ class Wiki
end end
def webs 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 end
def storage_path def storage_path