Skip to content

Instantly share code, notes, and snippets.

@qrush
Created July 27, 2008 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qrush/2809 to your computer and use it in GitHub Desktop.
Save qrush/2809 to your computer and use it in GitHub Desktop.
def self.find_by_permalink(link)
cat = nil
if link.to_i == 0
cat = Category.find_by_name(link.gsub(/ /, "-").titlecase)
else
cat = Category.find(link)
end
raise ActiveRecord::RecordNotFound, "Category not found" if cat.nil?
return cat
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment