Yes, give me :five! Enough :first and :all, I want to find :five.
In order to do this, I checked the source code of find :first and find :all in base.rb
OK, the next step is easy, override this method by defining a class method of a Model class, let's say, Blog class and add :five argument in.
Use class << self to open the Blog class object and add the find method in to override the original one. You have to implement :first and :all again. Otherwise the "Blog.find :all" will not work.
Now, you can use find :five to retrive the fifth elements:
No comments:
Post a Comment