Example: if a ''foo'' has 3 ''bars'', bars_count == "0" # ERROR bars.count == 3 # OK It looks like a bug to me. Alain -- Posted via http://www.ruby-forum.com/.
Rodrigo Alvarez Fernández
2005-Dec-19 00:17 UTC
Re: [Bug?] in tests, @foo.bars_count <> @foo.bars.count
On 12/19/05, Alain Ravet <alainravet-spam2004-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> > Example: if a ''foo'' has 3 ''bars'', > > bars_count == "0" # ERROR > bars.count == 3 # OKAnd what about collection.size and collection_count? Which should be used and in what case? It looks like a bug to me.> > Alain > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Alain Ravet wrote: > bars_count == "0" # ERROR > bars.count == 3 # OK I should have added that I use a count cache on the "foo" table. => there is a "bars_count" column in the ''foo'' table, BUT I didn''t initialize it, as the bars are added in another fixture: bars.yml => my test class starts with fixture :foos, :bars It looks like counters caches are not initialized by fixtures. Alain -- Posted via http://www.ruby-forum.com/.