Updated

db/migrate / 20150913074747_set_last_petition_created_at.rb

A
18 lines of codes
3 methods
1.9 complexity/method
1 churn
5.62 complexity
0 duplications
class SetLastPetitionCreatedAt < ActiveRecord::Migration
  1. SetLastPetitionCreatedAt has no descriptive comment
class Petition < ActiveRecord::Base; end
  1. SetLastPetitionCreatedAt::Petition has no descriptive comment
class Site < ActiveRecord::Base; end
  1. SetLastPetitionCreatedAt::Site has no descriptive comment
def up Site.update_all(last_petition_created_at: last_petition_created_at) end def down
  1. SetLastPetitionCreatedAt#down doesn't depend on instance state (maybe move it to another class?)
Site.update_all(last_petition_created_at: nil) end private def last_petition_created_at
  1. SetLastPetitionCreatedAt#last_petition_created_at doesn't depend on instance state (maybe move it to another class?)
Petition.maximum(:created_at) || Time.current end end