Ticket #9564: default_layouts_with_register_alias.patch
| File default_layouts_with_register_alias.patch, 1.9 kB (added by lifofifo, 1 year ago) |
|---|
-
actionpack/test/controller/mime_responds_test.rb
old new 116 116 117 117 def iphone_with_html_response_type 118 118 Mime::Type.register_alias("text/html", :iphone) 119 119 request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone" 120 120 121 respond_to do |type| 121 122 type.html { @type = "Firefox" } 122 123 type.iphone { @type = "iPhone" } -
actionpack/lib/action_controller/layout.rb
old new 234 234 235 235 protected 236 236 def render_with_a_layout(options = nil, &block) #:nodoc: 237 if template_with_options = options.is_a?(Hash) 238 response.template.template_format = options[:content_type].to_sym if options[:content_type] 239 end 240 237 template_with_options = options.is_a?(Hash) 238 set_template_format(options) 239 241 240 if apply_layout?(template_with_options, options) && (layout = pick_layout(template_with_options, options)) 242 241 assert_existence_of_template_file(layout) 243 242 … … 307 306 self.class.send(:layout_directory_exists_cache)[File.dirname(template_path)] 308 307 end 309 308 end 309 310 def set_template_format(options) 311 if options.is_a?(Hash) && options[:content_type] 312 response.template.template_format = options[:content_type].to_sym 313 elsif params[:format] 314 response.template.template_format = Mime::Type.lookup(Mime::Type.lookup_by_extension(params[:format]).to_s).to_sym 315 end 316 end 310 317 end 311 318 end