changeset 321:fec39456dcbe

Better request format checker. Didn't quite work when using curl.
author edogawaconan <me@myconan.net>
date Sun, 06 Apr 2014 03:20:10 +0900
parents 612bc7c32324
children 2235aa625af0
files app/controllers/pastes_controller.rb
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/pastes_controller.rb	Sun Apr 06 03:04:43 2014 +0900
+++ b/app/controllers/pastes_controller.rb	Sun Apr 06 03:20:10 2014 +0900
@@ -72,11 +72,11 @@
       correct_path == request.fullpath
   end
 
-  def cache_key(format = request.format)
+  def cache_key(format = request.format.symbol)
     ext = case format
-          when Mime::TXT
+          when :txt
             ".txt"
-          when Mime::HTML
+          when :html, nil
             ""
           else
             ".unknown"
@@ -91,7 +91,7 @@
   end
 
   def uncache
-    [Mime::TXT, Mime::HTML, "others"].each do |format|
+    [:txt, :html, :unknown].each do |format|
       Rails.cache.delete cache_key(format)
     end
   end