myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2465] trunk/app/controllers/comments_controller.


From: noreply
Subject: [myexperiment-hackers] [2465] trunk/app/controllers/comments_controller.rb: Be robust with params so we fail gracefully if they're not dates.
Date: Fri, 9 Jul 2010 13:04:16 -0400 (EDT)

Revision
2465
Author
dtm
Date
2010-07-09 13:04:16 -0400 (Fri, 09 Jul 2010)

Log Message

Be robust with params so we fail gracefully if they're not dates. (Some search
engines are asking for eg start=REPL_START).

Modified Paths

Diff

Modified: trunk/app/controllers/comments_controller.rb (2464 => 2465)


--- trunk/app/controllers/comments_controller.rb	2010-07-08 10:25:07 UTC (rev 2464)
+++ trunk/app/controllers/comments_controller.rb	2010-07-09 17:04:16 UTC (rev 2465)
@@ -10,7 +10,13 @@
 
   # GET /:context_type/:context_id/comments
   def index
-    @comments = Comment.find(:all, :conditions => [ "commentable_id = ? AND commentable_type = ? AND created_at > ? AND created_at < ?", @context.id, @context.class.name, params[:start].to_time, params[:end].to_time ] )
+    if params[:start] && params[:end]
+      begin
+        @comments = Comment.find(:all, :conditions => [ "commentable_id = ? AND commentable_type = ? AND created_at > ? AND created_at < ?", @context.id, @context.class.name, params[:start].to_time, params[:end].to_time ] )
+      rescue TypeError
+      end
+    end
+    @comments ||= []
     respond_to do |format|
       format.json { render :partial => 'comments/timeline_json', :layout => false }
     end

reply via email to

[Prev in Thread] Current Thread [Next in Thread]