Not .all! that will fetch all records into memory before counting.
Invitation.any? or if that's unavailable then .count > 0


On Wed, Feb 26, 2014 at 6:01 PM, James Kiesel <notifications@github.com>wrote:

> In db/migrate/20140206023957_make_invitations_polymorphic.rb:
>
> > @@ -0,0 +1,47 @@
> > +class MakeInvitationsPolymorphic < ActiveRecord::Migration
> > +  def up
> > +    change_table :invitations do |t|
> > +      t.references :invitable, polymorphic: true
> > +    end
> > +
> > +    Invitation.reset_column_information
> > +    ActiveRecord::Base.record_timestamps = false
> > +    begin
> > +      puts "Updating #{Invitation.last.id} Invitation records to polymorphic"
>
> This breaks if there aren't Invitations in the DB already; needs something
> like
> if Invitation.all.any?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/loomio/loomio/pull/1276/files#r10068537>
> .
>