Skip to content

Instantly share code, notes, and snippets.

@fellix
Created February 13, 2011 01:02
Show Gist options
  • Save fellix/824310 to your computer and use it in GitHub Desktop.
Save fellix/824310 to your computer and use it in GitHub Desktop.
def self.find_by_url(friendly_id)
result = self.joins("JOIN slugs ON slugs.sluggable_id = posts.id and slugs.sluggable_type = 'Post'").where("slugs.name = ?", friendly_id).first
raise ActiveRecord::RecordNotFound unless result
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment