update_all is a method provided by ActiveRecord, and you have Array, you have two options: use ActiveRecord through comments (update the database) or map the array, changing only objects in memory and not changing the database:
comments = Comments.update_all({:test => nil}, 'test IS NOT NULL')
or
comments = Comments.find(:all,:conditions => ["test is not null"]) comments.map! { |c| c.test = nil unless c.test}
EDIT: Error in second example, c.test not c
source share