In my Rails3 app I have AR scope which requires 3 parameters
Ex: I’m trying to get an error details for a given module between two code values
#select * from error_codes where error_module_id=1 and code >0 and code < 100
scope :latest_error_code, lambda{ |module_id, min, max|
{:conditions => "error_module_id=#{module_id} and code >= #{min} and code <= #{max}"}
}
in my console I do
ErrorCode.latest_error_code(1,0,100)
But when I try to execute this, I’m getting the following error
multiple values for a block parameter (3 for 1)
and when i did some goggling, it appears to be that AR scope doent support multiple parameters
1 – is it true? (AR doent support multiple params for scope)
2 – Is there any other alternative?
3 – Am I doing something wrong here?
thanks in advance
From the Active Record Query Interface Guide:
So you probably want something more like this: