提交 ec73710c 编写于 作者: J José Valim

Alleviate the pain in working with utf8 templates by setting a default encoding.

上级 48634bf5
......@@ -6,21 +6,29 @@ class Configuration < ::Rails::Engine::Configuration
include ::Rails::Configuration::Deprecated
attr_accessor :allow_concurrency, :cache_classes, :cache_store,
:secret_token, :consider_all_requests_local, :dependency_loading,
:encoding, :consider_all_requests_local, :dependency_loading,
:filter_parameters, :log_level, :logger, :metals,
:plugins, :preload_frameworks, :reload_engines, :reload_plugins,
:serve_static_assets, :time_zone, :whiny_nils
:secret_token, :serve_static_assets, :time_zone, :whiny_nils
def initialize(*)
super
@allow_concurrency = false
@filter_parameters = []
@dependency_loading = true
@allow_concurrency = false
@consider_all_requests_local = false
@encoding = "utf-8"
@filter_parameters = []
@dependency_loading = true
@serve_static_assets = true
@time_zone = "UTC"
@consider_all_requests_local = true
@session_store = :cookie_store
@session_options = {}
@time_zone = "UTC"
end
def encoding=(value)
@encoding = value
if defined?(Encoding) && Encoding.respond_to?(:default_external=)
Encoding.default_external = value
end
end
def middleware
......
......@@ -46,6 +46,9 @@ class Application < Rails::Application
# g.test_framework :test_unit, :fixture => true
# end
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters << :password
end
......
......@@ -172,6 +172,18 @@ def teardown
assert $prepared
end
test "config.encoding sets the default encoding" do
add_to_config <<-RUBY
config.encoding = "utf-8"
RUBY
require "#{app_path}/config/application"
unless RUBY_VERSION < '1.9'
assert_equal Encoding.find("utf-8"), Encoding.default_external
end
end
def make_basic_app
require "rails"
require "action_controller/railtie"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册