Created
June 29, 2014 09:16
-
-
Save dramforever/8c64cf6c683a5d663d52 to your computer and use it in GitHub Desktop.
wih-annotation 9f06ef
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 9f06ef6f88d2f9d6bfd40988bc7b7e667021f0d9 Mon Sep 17 00:00:00 2001 | |
From: dramforever <[email protected]> | |
Date: Sun, 29 Jun 2014 17:11:46 +0800 | |
Subject: [PATCH] Fix sth | |
--- | |
app/controllers/images_controller.rb | 12 ++++-------- | |
1 file changed, 4 insertions(+), 8 deletions(-) | |
diff --git a/app/controllers/images_controller.rb b/app/controllers/images_controller.rb | |
index 805fdf2..49f3096 100755 | |
--- a/app/controllers/images_controller.rb | |
+++ b/app/controllers/images_controller.rb | |
@@ -11,20 +11,16 @@ class ImagesController < ApplicationController | |
elsif params[:gender] == "boy" | |
gender = 0 | |
else | |
- raise | |
+ raise "Parameter gender invalid. Must be girl or boy" | |
end | |
imgs = Image.where("gender = #{gender} AND has_inspect = ?", true).all | |
- length = imgs.count | |
- if length<2 | |
+ if imgs.count < 2 | |
raise "Too few pictures." | |
end | |
- random1 = imgs.sample | |
- random2 = imgs.sample | |
+ random1, random2 = imgs.sample 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment