Railsisms
Use some ActiveRecord convenience methods.
This commit is contained in:
parent
13d096c688
commit
6c0decc4ea
|
@ -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|
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue