# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base # Pick a unique cookie name to distinguish our session data from others' session :session_key => '_plog_session_id' before_filter :login_from_cookie def hobo_render_tag(tag) Hobo::Dryml.render_tag(@template, tag, :obj => @this) end ########################################################### ################ Boring Charset Stuff ##################### ########################################################### # to tell mysql to use utf-8 before_filter :configure_charsets # to fix a Safari + AJAX charset bug: after_filter :set_charset def configure_charsets # Set connection charset. MySQL 4.0 doesn't support this so it # will throw an error, MySQL 4.1 needs this if ActiveRecord::Base.connection.adapter_name == "MySQL" suppress(ActiveRecord::StatementInvalid) do ActiveRecord::Base.connection.execute 'SET NAMES UTF8' end end end # Needed to fix a Safari + AJAX bug. def set_charset content_type = headers["Content-Type"] || 'text/html' if /^text\//.match(content_type) && !/.*; charset=.*/.match(content_type) headers["Content-Type"] = "#{content_type}; charset=UTF-8" end end end