class ApplicationController
def force_utf8_params
See https://rails.lighthouseapp.com/projects/8994/tickets/4807
See http://stackoverflow.com/questions/8268778/rails-2-3-9-encoding-of-query-parameters
That's what's happening in Rails 3, too: https://github.com/rails/rails/commit/25215d7285db10e2c04d903f251b791342e4dd6a
That's why we force the encoding of the params to UTF-8
That causes problems, especially when using special chars and with certain DBs, like DB2
When using TrustyCms with Ruby 1.9, the strings that come in from forms are ASCII-8BIT encoded.
def force_utf8_params traverse = lambda do |object, block| if object.kind_of?(Hash) object.each_value { |o| traverse.call(o, block) } elsif object.kind_of?(Array) object.each { |o| traverse.call(o, block) } else block.call(object) end object end force_encoding = lambda do |o| o.force_encoding(Encoding::UTF_8) if o.respond_to?(:force_encoding) end traverse.call(params, force_encoding) end
def initialize
def initialize super @trusty_config = TrustyCms::Config end
def set_current_user
def set_current_user UserActionObserver.instance.current_user = current_user end
def set_javascripts_and_stylesheets
def set_javascripts_and_stylesheets @stylesheets ||= [] @stylesheets.concat %w(admin/main) @javascripts ||= [] end
def set_mailer
def set_mailer ActionMailer::Base.default_url_options[:host] = request.host_with_port end
def set_standard_body_style
def set_standard_body_style @body_classes ||= [] @body_classes.concat(%w(reversed)) end
def set_timezone
def set_timezone Time.zone = TrustyCms::Config['local.timezone'] != nil && TrustyCms::Config['local.timezone'].empty? ? Time.zone_default : TrustyCms::Config['local.timezone'] end
def set_user_locale
def set_user_locale I18n.locale = current_user && !current_user.locale.blank? ? current_user.locale : TrustyCms::Config['default_locale'] end
def template_name
def template_name case self.action_name when 'index' 'index' when 'new','create' 'new' when 'show' 'show' when 'edit', 'update' 'edit' when 'remove', 'destroy' 'remove' else self.action_name end end