Created
March 13, 2012 01:36
-
-
Save rondy/2026070 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
Article.all( | |
:select => "articles.id, articles.title, slugs.name", | |
:joins => "INNER JOIN slugs | |
ON slugs.sluggable_type = 'Article' AND | |
slugs.sluggable_id = articles.id AND | |
slugs.id = (SELECT id | |
FROM slugs | |
WHERE slugs.sluggable_type = 'Article' AND | |
slugs.sluggable_id = articles.id | |
ORDER BY slugs.created_at DESC | |
LIMIT 1)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh yeah, subselects