This project is archived and is in readonly mode.

#5003 ✓resolved
John Henderson

default_scope prevents a rake db:migrate if attributes in DB don't exist

Reported by John Henderson | June 29th, 2010 @ 12:31 PM | in 3.0.2

Rails version 3 beta 4

I just discovered that if I declared the following in the User model for example:

default_scope :conditions => { :cancelled_at => nil }

and run rake db:migrate on an empty database I get:

rake aborted!
No attribute named `cancelled_at` exists for table `users`

The following code gets around the problem, but it's not pretty.

default_scope do 
  { :conditions => { :cancelled_at => nil } }
end

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Referenced by

Pages