On Wed, Jul 22, 2009 at 12:02 AM, Dingding Ye <yedingd...@gmail.com> wrote:

> Seems it's a bug of 2.3.2 and fixed in 2.3.3.
> Best regards.
>
> sishen
>
>
> On Sat, Jul 11, 2009 at 11:55 PM, Michal Burak <
> rails-mailing-l...@andreas-s.net> wrote:
>
>>
>> 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


>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to