Skip to content

Instantly share code, notes, and snippets.

@rlburkes
Last active August 29, 2015 13:56
Show Gist options
  • Save rlburkes/8825832 to your computer and use it in GitHub Desktop.
Save rlburkes/8825832 to your computer and use it in GitHub Desktop.
class MarkProductExportsWhichMeetAllRequirements < ActiveRecord::Migration
class Export < ActiveRecord::Base
attr_accessible :meets_requirements
def meets_all_requirements?
# Do some complex business logic which cannot be expressed via sql query
end
end
def up
Export.where(type: 'ProductExport').find_each do |product_export|
product_export.update_attributes!(meets_requirements: product_export.meets_all_requirements?)
end
end
def down
# ...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment