I hereby claim:
- I am jondahl on github.
- I am jondahl (https://keybase.io/jondahl) on keybase.
- I have a public key ASB5sEzrI01_cIXCStV1CH84V067GeRHa6I2qK_aVCS1UAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
when :restrict | |
method_name = "has_many_dependent_restrict_for_#{reflection.name}".to_sym | |
define_method(method_name) do | |
unless send(reflection.name).empty? | |
# change to named error... | |
raise ActiveRecord::StatementInvalid, "can't delete record because of dependent #{reflection.name}" | |
end | |
end | |
before_destroy method_name |
# | |
# Copyright (c) 2009 Jonathan Dahl | |
# | |
# Released under the MIT license. See below for details. | |
# | |
namespace :db do | |
namespace :data do | |
desc "Anonymize sensitive information" | |
task :anonymize => :environment do |
namespace :db do | |
namespace :data do | |
desc "Find all invalid ActiveRecord records" | |
task :invalid_records => :environment do | |
models = Object.subclasses_of(ActiveRecord::Base) | |
models.each do |model| | |
begin | |
model.all.each do |record| | |
if !record.valid? | |
puts "#{model} #{record.id} is invalid: #{record.errors.full_messages.to_sentence}" |