Skip to content

Instantly share code, notes, and snippets.

@ncherro
Created April 23, 2012 00:44
Show Gist options
  • Save ncherro/2467835 to your computer and use it in GitHub Desktop.
Save ncherro/2467835 to your computer and use it in GitHub Desktop.
Rails extension to add Permalink functionality to any model. To use, place in /app/models/extensions/permalink.rb
class ExampleModel < ActiveRecord::Base
# include the module
include Extensions::Permalink
# make sure there's a method named "unicode" that
# returns the string you'd like to sluggify
def unicode
self.name
end
end
@ncherro
Copy link
Author

ncherro commented Apr 23, 2012

The model must have a 'unicode' method, which returns the field to be used as the permalink.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment