I have a method as follows...
def self.get(code)
where(code: normalize_code(code)).
where('coupon_count > 0').
where('expires_at > Time.now OR expires_at IS NULL').
take
end
I keep getting the error "wrong number of arguments (0 for 1)" on the "take" line. I am using rails 4.0.1 is that causing the problem or am I missing something?
EDIT Looking at the docs for 4.0.1 http://rails.documentation.codyrobbins.com/4.0.10/classes/ActiveRecord/FinderMethods.html#method-i-take
I updated the method to
def self.get(code)
where(code: normalize_code(code)).
where('coupon_count > 0').
where('expires_at > Time.now OR expires_at IS NULL').
take(1)
end
Now I get the error
SyntaxError: Unexpected identifier (16722)
The error is on the "take" line
-UPDATE-
My error is in the where method for coupon_count. It is not in the take method. I have to figure out what it wont check the coupon_count field before accepting the coupon.