hakanensari/mongoid-slug — Issue #44: Rewrite to_param to to_slug
Author: bendangelo
Created: 2012-01-09 02:35:01+00:00
State: open

In one of my models I used to_param like so

def to_param
self.token
end

And in special cases I would use the slug aswell. This created an issue because I have no way of getting the slug without to_param. This was my solution:

alias :super_to_param :to_param
def to_param
self.token
end

def to_slug
"#{self.token}/#{super_to_param()}"
end