Skip to content

Instantly share code, notes, and snippets.

@brennandunn
Created July 22, 2008 19:57
Show Gist options
  • Save brennandunn/1243 to your computer and use it in GitHub Desktop.
Save brennandunn/1243 to your computer and use it in GitHub Desktop.
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