Thanks guys for all your replies. Im using mysql locally.

I think its down to ruby versino differences. Anyway I changed it from count
to length and all works fine now. Strange though.

On Thu, May 13, 2010 at 9:07 AM, Sunny Beach <[email protected]>wrote:

> Another related question, which database are you using locally?
>
> I had problems developing stuff that worked fine with sqlite locally but
> did not work with postgres out on heroku. Custome sql -- like your named
> scope -- was my problem. From what I remember, LIKE is actually ILIKE in
> postgres if you want case insensitive results.
>
> Sunny
>
>
> On Wed, May 12, 2010 at 6:10 PM, Jonathan Dance <[email protected]> wrote:
>
>> I'd recommend using Array#size, not Array#count. Only use #count when your
>> intent is to invoke a COUNT() query in SQL. I try to use #size for arrays
>> and reserve #length for strings.
>>
>> If your intent was to invoke a COUNT() query, you'll want to use
>> named_scopes all the way through, as such:
>>
>> def checked_sentence_since_last_login
>>   self.sentences.checked.scoped(:conditions => ["checked_at
>> > ?", last_login_at])
>> end
>>
>> That said, you *can* use Array#count, as it is defined in Ruby 1.8.7 and
>> 1.9.1 but not 1.8.6. Note that these are Sinatra apps:
>>
>> % heroku console --app aspen-mri186
>> >> [].count
>> NoMethodError: undefined method `count' for []:Array
>>
>> % heroku console --app bamboo-ree187
>> >> [].count
>> => 0
>>
>> % heroku console --app bamboo-mri191
>> >> [].count
>> => 0
>>
>> --wuputah
>>
>> On Mon, May 10, 2010 at 10:37 PM, adam <[email protected]> wrote:
>>
>>> My heroku app is tripping over code at the point where i try to do a
>>> count on an empty array. But in development on my local machine with
>>> the very same database and code (taps db:pull) it doesnt trip up.
>>>
>>> can anyone tell me why this is? im using ruby 1.8.7 and rails 2.3.2
>>>
>>> below is the offending line which produces the error NoMethodError
>>> (undefined method `count' for []:Array):
>>>
>>>
>>> @recently_checked_sentences_count =
>>> @user.checked_sentences_since_last_login.count
>>>
>>> with method below
>>>
>>> def checked_sentences_since_last_login()
>>>    self.sentences.checked.find(:all, :conditions => ["checked_at
>>> > ?", last_login_at])
>>>  end
>>>
>>> which uses named_scope
>>>
>>> named_scope :checked,  lambda{|limit| { :limit => limit, :order =>
>>> "checked_at DESC", :conditions => "checked_at IS NOT NULL" } }
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Heroku" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<heroku%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/heroku?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Heroku" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<heroku%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/heroku?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Heroku" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<heroku%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/heroku?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.

Reply via email to