Seems it’s a bug of 2.3.2 and fixed in 2.3.3.
Best regards.
sishen
Seems it’s a bug of 2.3.2 and fixed in 2.3.3.
Best regards.
sishen
Seems it’s a bug of 2.3.2 and fixed in 2.3.3.
Best regards.
sishen
Hi,
Rails 2.3.2
class TestD < ActiveRecord::Base
default_scope :limit => 12
named_scope :limit, lambda { |num| { :limit => num} }
end
ruby script/console
TestD.all
TestD Load (0.7ms) SELECT * FROM “test_ds” LIMIT 12
=>
TestD.limit(14)
TestD Load (0.3ms) SELECT * FROM “test_ds” LIMIT 12
=>
Any ideas why the default limit does not get overwritten?
M.
–
Posted via http://www.ruby-forum.com/.
This works for me in Rails 2.3.3. For example, given the following named scopes:
default_scope :limit => 12
named_scope :recent, lambda { |limit| { :order => “posted_at DESC”, :limit => limit } }
named_scope :limit, lambda { |limit| { :order => “posted_at DESC”, :limit => limit } }
Episode.all
=> SELECT * FROM episodes
LIMIT 12
SHOW FIELDS FROM episodes
Episode.recent(10)
=> SELECT * FROM episodes
ORDER BY posted_at DESC LIMIT 10
Episode.limit(10)
=> SELECT * FROM episodes
ORDER BY posted_at DESC LIMIT 10
-Conrad