Closed
Description
Consider following models
class Customers < ActiveRecord::Base
has many :orders
end
class Order < ActiveRecord::Base
scope :ordered, order('created_at DESC')
belongs_to :customer
end
Calling following
customer.orders.ordered.to_sql
will result in following sql code:
SELECT "orders".* FROM "orders" ORDER BY created_at DESC
I consider this important issue, as it's quite easy just to forget using lambda syntax and results are far from expected. Lambda syntax is quite big change in Rails4 and I suspect, that many people will forget about using it. In my opinion exception should be raised in such situations.
This is somehow connected to not yet merged #10528 and issue #10421 - so this ticket just aims to show how serious situation is.
Due to not merged #10528, it's still an issue on branch 4-0-stable.