Created
May 21, 2013 05:16
-
-
Save daybreaker/5617610 to your computer and use it in GitHub Desktop.
This file contains 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
# model | |
class Survey < ActiveRecord::Base | |
CONDITIONS = ["surveys.hotel_id IS NOT NULL"] | |
end | |
# controller | |
conditions = Survey::CONDITIONS | |
unless params[:time_period].blank? | |
conditions << "surveys.created_at > '#{params[:time_period].to_i.months.ago}'" | |
end | |
logger.info conditions.inspect | |
# locally, conditions.inspect will always have only one condition fpr the created_at, eg: | |
# ["surveys.hotel_id IS NOT NULL", "surveys.created_at > '2011-05-21 01:08:19 -0400'"] | |
# On Amazon EC2, they keep getting added on, eg: | |
# ["surveys.hotel_id IS NOT NULL", "surveys.created_at > '2011-05-21 01:08:19 -0400'", "surveys.created_at > '2012-05-21 01:08:37 -0400'"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment