diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-02-03 22:49:56 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-02-03 22:49:56 +0000 |
commit | c0eeb9f1e20af2a5c4f77c71fd1236e6c1584f05 (patch) | |
tree | e92a7bfd6def8b7fce289476c406a8101f9a2681 /actionpack/lib | |
parent | 9f030acf22696a476578e9ccde9984fa1b86f02c (diff) | |
parent | 34a37ea9e8265972a93f0c4f62e44308c27751dd (diff) | |
download | rails-c0eeb9f1e20af2a5c4f77c71fd1236e6c1584f05.tar.gz rails-c0eeb9f1e20af2a5c4f77c71fd1236e6c1584f05.tar.bz2 rails-c0eeb9f1e20af2a5c4f77c71fd1236e6c1584f05.zip |
Merge commit 'mainstream/master'
Conflicts:
railties/doc/guides/html/action_mailer_basics.html
railties/doc/guides/html/getting_started_with_rails.html
railties/doc/guides/html/i18n.html
railties/doc/guides/source/action_mailer_basics.txt
railties/doc/guides/source/getting_started_with_rails.txt
railties/doc/guides/source/i18n.txt
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/rescue.rb | 16 | ||||
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 9 | ||||
-rw-r--r-- | actionpack/lib/action_view/partials.rb | 21 | ||||
-rw-r--r-- | actionpack/lib/action_view/template.rb | 2 |
4 files changed, 32 insertions, 16 deletions
diff --git a/actionpack/lib/action_controller/rescue.rb b/actionpack/lib/action_controller/rescue.rb index 4b7d1e32fd..ec61715b57 100644 --- a/actionpack/lib/action_controller/rescue.rb +++ b/actionpack/lib/action_controller/rescue.rb @@ -99,13 +99,19 @@ module ActionController #:nodoc: # Attempts to render a static error page based on the # <tt>status_code</tt> thrown, or just return headers if no such file - # exists. For example, if a 500 error is being handled Rails will first - # attempt to render the file at <tt>public/500.html</tt>. If the file - # doesn't exist, the body of the response will be left empty. + # exists. At first, it will try to render a localized static page. + # For example, if a 500 error is being handled Rails and locale is :da, + # it will first attempt to render the file at <tt>public/500.da.html</tt> + # then attempt to render <tt>public/500.html</tt>. If none of them exist, + # the body of the response will be left empty. def render_optional_error_file(status_code) status = interpret_status(status_code) - path = "#{Rails.public_path}/#{status.to_s[0,3]}.html" - if File.exist?(path) + locale_path = "#{Rails.public_path}/#{status[0,3]}.#{I18n.locale}.html" if I18n.locale + path = "#{Rails.public_path}/#{status[0,3]}.html" + + if locale_path && File.exist?(locale_path) + render :file => locale_path, :status => status, :content_type => Mime::HTML + elsif File.exist?(path) render :file => path, :status => status, :content_type => Mime::HTML else head status diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 0b0d0c799b..d2059d51f4 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -127,9 +127,14 @@ module ActionController # # The exception is stored in the exception accessor for further inspection. module RaiseActionExceptions - protected - attr_accessor :exception + def self.included(base) + base.class_eval do + attr_accessor :exception + protected :exception, :exception= + end + end + protected def rescue_action_without_handler(e) self.exception = e diff --git a/actionpack/lib/action_view/partials.rb b/actionpack/lib/action_view/partials.rb index 59e82b98a4..9e5e0f786e 100644 --- a/actionpack/lib/action_view/partials.rb +++ b/actionpack/lib/action_view/partials.rb @@ -187,15 +187,20 @@ module ActionView builder_partial_path = partial_path.class.to_s.demodulize.underscore.sub(/_builder$/, '') local_assigns.merge!(builder_partial_path.to_sym => partial_path) render_partial(:partial => builder_partial_path, :object => options[:object], :locals => local_assigns) - when Array, ActiveRecord::Associations::AssociationCollection, ActiveRecord::NamedScope::Scope - render_partial_collection(options.except(:partial).merge(:collection => partial_path)) else - object = partial_path - render_partial( - :partial => ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path), - :object => object, - :locals => local_assigns - ) + if Array === partial_path || + (defined?(ActiveRecord) && + (ActiveRecord::Associations::AssociationCollection === partial_path || + ActiveRecord::NamedScope::Scope === partial_path)) + render_partial_collection(options.except(:partial).merge(:collection => partial_path)) + else + object = partial_path + render_partial( + :partial => ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path), + :object => object, + :locals => local_assigns + ) + end end end diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index 1361a969a9..553158b82a 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -133,7 +133,7 @@ module ActionView #:nodoc: end def mime_type - Mime::Type.lookup_by_extension(format) if format + Mime::Type.lookup_by_extension(format) if format && defined?(::Mime) end memoize :mime_type |