Rails set db table values to nil

I have huge db, and in one table i want to set somefield to nil, how can i do this? When i do like that:

@act = Article.all
 @act.each do |aaa|
   aaa.name = nil
 end

But this loads system, how to do this in more faster and better way?

Answers


Just do it like this:

Article.update_all(:name => nil)

This will go directly to the database, without loading the objects.


Need Your Help

Android:Sqlite tables

android sqlite table

I have created tables in android sqlite using create statement and also inserted values into it.

Deploying a Laravel 4 app on AWS Elastic Beanstalk

php amazon-web-services laravel laravel-4 elastic-beanstalk

I've developed an application in Laravel 4 - works perfectly on my local machine with the usual/typical laravel setup (nothing unusual going on here).