courtenay / altered_beast

Ground-up rewrite of Beast, a Ruby on Rails forum.

This URL has Read+Write access

courtenay (author)
Tue Oct 14 15:51:56 -0700 2008
commit  bd2322c7877d3f51daf9ea7320a25a0219896305
tree    96e6e8256347c9822ce80cff18b5a0c6bbbed4e7
parent  94f575daace57ebeca4db0af9abec01bdcade50f parent  80228688c179a6d05405c653631a4fab5616c006
altered_beast / config / initializers / active_record.rb
100644 24 lines (21 sloc) 0.675 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class ActiveRecord::Base
  @@white_list_sanitizer = HTML::WhiteListSanitizer.new
  class << self
    attr_accessor :formatted_attributes
  end
 
  cattr_reader :white_list_sanitizer
 
  def self.formats_attributes(*attributes)
    (self.formatted_attributes ||= []).push *attributes
    before_save :format_attributes
    send :include, HtmlFormatting, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper
  end
 
  def self.paginated_each(options = {}, &block)
    page = 1
    records = [nil]
    until records.empty? do
      records = paginate(options.update(:page => page, :count => {:select => '*'}))
      records.each &block
      page += 1
    end
  end
end