Test

Ruby code posted by Bob
created at 31 Jan 19:45

Edit | Back
1
2
3
4
5
6
7
8
9
10
class User < ActiveRecord::Base
  named_scope :inactive, :conditions => {:active => false} do
    def activate
      each { |i| i.update_attribute(:active, true) }
    end
  end
end

# Re-activate all inactive users
User.inactive.activate
249 Bytes in 3 ms with coderay