Hi, this is actually in response to the following thread... http://groups.google.com/group/rubyonrails-core/browse_thread/thread/4446f6766b2434d8 ...but Google Groups keeps giving me an error when I try to reply there. I''m unable to run db:schema:load because it loads the Rails environment, the environment loads my models, and my models have scopes, which query the database. This is on Rails 3.0.5 and Ruby 1.8.7 on OSX. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Another developer and I have done some more digging on this and determined that it only happens on the one model in our app which has scopes and is subclassing another model with STI. It does stop happening if we remove all our observers and comment out calls to Devise in routes.rb, but that''s not really an option... On Sun, Mar 13, 2011 at 11:03 PM, Lawrence Wang <levity@gmail.com> wrote:> Hi, this is actually in response to the following thread... > > http://groups.google.com/group/rubyonrails-core/browse_thread/thread/4446f6766b2434d8 > ...but Google Groups keeps giving me an error when I try to reply > there. > > I''m unable to run db:schema:load because it loads the Rails > environment, the environment loads my models, and my models have > scopes, which query the database. This is on Rails 3.0.5 and Ruby > 1.8.7 on OSX.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
do you mind gist us the test case, or your bare model which would cost the error to occur? Thanks Prem On 14 มี.ค. 2554, at 10:03, Lawrence Wang wrote:> Hi, this is actually in response to the following thread... > http://groups.google.com/group/rubyonrails-core/browse_thread/thread/4446f6766b2434d8 > ...but Google Groups keeps giving me an error when I try to reply > there. > > I''m unable to run db:schema:load because it loads the Rails > environment, the environment loads my models, and my models have > scopes, which query the database. This is on Rails 3.0.5 and Ruby > 1.8.7 on OSX. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
So yeah, Devise is to blame here (it does the loading). Solution - define your scopes with blocks, i.e. change class Post scope :active, where(:active => true) end to class Post scope :active, proc { where(:active => true) } end On 3/14/2011 7:08 AM, Lawrence Wang wrote:> Another developer and I have done some more digging on this and > determined that it only happens on the one model in our app which has > scopes and is subclassing another model with STI. It does stop happening > if we remove all our observers and comment out calls to Devise in > routes.rb, but that''s not really an option... > > On Sun, Mar 13, 2011 at 11:03 PM, Lawrence Wang <levity@gmail.com > <mailto:levity@gmail.com>> wrote: > > Hi, this is actually in response to the following thread... > http://groups.google.com/group/rubyonrails-core/browse_thread/thread/4446f6766b2434d8 > ...but Google Groups keeps giving me an error when I try to reply > there. > > I''m unable to run db:schema:load because it loads the Rails > environment, the environment loads my models, and my models have > scopes, which query the database. This is on Rails 3.0.5 and Ruby > 1.8.7 on OSX. > > > -- > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Thanks! Is there any workaround for when this happens due to default_scope? I see that it doesn''t support blocks yet. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On 3/19/2011 12:11 AM, Lawrence Wang wrote:> Thanks! Is there any workaround for when this happens due to > default_scope? I see that it doesn''t support blocks yet.Unfortunately - no, and if you want the whole story - check out this one https://rails.lighthouseapp.com/projects/8994/tickets/1812-default_scope-cant-take-procs -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.