[typo] Finding posts without a category

Kevin Ballard kevin at sb.org
Thu Aug 18 02:04:35 EDT 2005

On Aug 17, 2005, at 9:18 PM, Trejkaz wrote:

> This is probably a silly question, but is there a way I can easily  
> find all
> posts without a category assigned?  I want to make sure everything  
> has at least
> one category, but at the moment it's a bit tedious to go hunting  
> for them.

I'd imagine the following would work:

./script/runner 'Article.find(:all, :include => [:categories]).reject  
{ |a| a.has_categories? }.each { |a| p a }'

Of course, I don't know for certain because all my articles have  
categories, so it prints nothing for me.

If you want to run this on production, add --environment=production  
as a second argument.

Kevin Ballard
kevin at sb.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2378 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/typo-list/attachments/20050818/94640113/smime.bin

More information about the Typo-list mailing list