Reputation: 2689
I was able to setup friendly_id with one of my models (categories), but I need help with setting up with another model.
Basically I want the URL's to be something like this: domain.com/129121/title-of-post
where 129121 is the ID of the post.
I tried doing this by updating the to_param
but it did not work (https://github.com/gitlabhq/gitlabhq/issues/7265).
Im not sure how to get SO style links working. Any help would be appreciated!
Upvotes: 0
Views: 83
Reputation: 15384
I tried something similar and come up with
def slug
name.downcase.gsub(" ", "-") # you can change name to the attribute that holds your title
end
def to_param
"#{self.id}-#{slug}"
end
Might get you on your way
Upvotes: 0