[Rails 3.0.7-10] Missing Scope + Includes breaks the Chain

Hello guys, found this issue in version 3.0.7, just working in the
same site with 3.0.10 and the same issue pops out.

Lets say we have a Classified site, so we have ads and pictures:

class Ad < ActiveRecord::Base
has_many :pictures

scope :active, where(“expires_on > now()”)
scope :unsold, where(“sold = 0”)
scope :approved, where("status = “approved”)
end

class Picture < ActiveRecord::Base
belongs_to :ad
end

Now lets run some tests and try to explain myself:

Ad.unsolds.to_sql
=> “SELECT ads.* FROM ads WHERE (sold = 0) ORDER BY ads.created_at
desc”

All good.

Ad.there_is_no_scope.unsolds.to_sql
=> NoMethodError: undefined method `there_is_no_scope’ for #<Class:
0xa41b7d4>

Awesome. Now comes the issue

Ad.includes(:picture).there_is_no_scope.unsolds.to_sql
=> NoMethodError:

I have 1.6M of records in my ads table, obviously I noted some kind of
hanging, the problem was,
Ad.includes(:picture).there_is_no_scope.unsolds.to_sql raise the
NoMethodError but also executes the query defined before the missing
scope, in this case “select * from ads”.

I can create an example application if this is not understandable.

Just want you guys to know about this issue.

Thanks.