ActiveRecord::Base.class_eval do
  include ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper
  def self.format_attribute(attr_name)
    class << self; include ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper; end
    define_method(:body)       { read_attribute attr_name }
    define_method(:body_html)  { read_attribute "#{attr_name}_html" }
    define_method(:body_html=) { |value| write_attribute "#{attr_name}_html", value }
    before_save :format_content
  end

  def dom_id
    [self.class.name.downcase.pluralize.dasherize, id] * '-'
  end

  protected
    def format_content
      body.strip! if body.respond_to?(:strip!)
      self.body_html = body.blank? ? '' : body_html_with_formatting
    end
    
    def body_html_with_formatting
      body_html = auto_link body { |text| truncate(text, 50) }
      textilized = RedCloth.new(body_html) #, [ :hard_breaks ])
#      textilized.hard_breaks = true if textilized.respond_to?("hard_breaks=")
      logger.info(textilized.to_html)
      white_list(textilized.to_html)
    end
end



ActiveRecord::Base.class_eval do
  include ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper
  def self.format_attribute(attr_name)
    class << self; include ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper; end
    define_method(:body)       { read_attribute attr_name }
    define_method(:body_html)  { read_attribute "#{attr_name}_html" }
    define_method(:body_html=) { |value| write_attribute "#{attr_name}_html", value }
    before_save :format_content
  end

  def dom_id
    [self.class.name.downcase.pluralize.dasherize, id] * '-'
  end

  protected
    def format_content
      body.strip! if body.respond_to?(:strip!)
      self.body_html = body.blank? ? '' : body_html_with_formatting
    end

    def body_html_with_formatting
      body_html = auto_link body { |text| truncate(text, 50) }
      textilized = RedCloth.new(body_html) #, [ :hard_breaks ])
#      textilized.hard_breaks = true if textilized.respond_to?("hard_breaks=")
      logger.info(textilized.to_html)
      HTML::WhiteListSanitizer.new.sanitize(textilized.to_html)
    end
end



Fix topic/post creation error. Now we use build in HTML::WhiteLIstSanitizer instaead of removed white_list plugin. But plugin white_list_formatted_content still needed.
Fix topic/post creation error. Now we use build in HTML::WhiteLIstSanitizer instaead of removed white_list plugin. But plugin white_list_formatted_content still needed.
