diff app/models/paste.rb @ 431:68eb23b52864

Rails 5 \o/
author nanaya <me@myconan.net>
date Fri, 13 May 2016 03:56:07 +0900
parents 9fc6b919369c
children b445318de858
line wrap: on
line diff
--- a/app/models/paste.rb	Tue Mar 01 16:36:10 2016 +0900
+++ b/app/models/paste.rb	Fri May 13 03:56:07 2016 +0900
@@ -17,7 +17,7 @@
   def self.safe_find(raw_id)
     /\A(?<id>[0-9]+)(?:-(?<secret>[0-9a-f]+))?\z/ =~ raw_id.to_s
 
-    where(:secret => secret, :id => id).take
+    find_by(:secret => secret, :id => id)
   end
 
   def self.graceful_create(params)
@@ -73,7 +73,7 @@
   end
 
   def convert_newlines
-    self.paste = paste.to_s.gsub("\r\n", "\n").gsub("\r", "\n")
+    self.paste = paste.to_s.gsub("\r\n", "\n").tr("\r", "\n")
   end
 
   def paste_limit