Created
July 22, 2008 19:57
-
-
Save brennandunn/1243 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def children(options = {}) | |
options.merge!({ :order => 'updated_at desc' }) | |
options # => {:limit=>3, :order=>"updated_at desc"} | |
found = articles.find(:all, options) | |
options # => {:conditions=>"`articles`.section_id = 2", :readonly=>nil, :select=>nil, :group=>nil, :offset=>nil, :limit=>3, :include=>:_route, :joins=>nil, :order=>"updated_at desc, created_at desc"} | |
found += pages.find(:all, options) | |
found.sort! { |x, y| y.updated_at <=> x.updated_at } | |
options[:limit] ? found[0, options[:limit]] : found | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment