-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to generate slugs for existing documents #68
Comments
Looks fine to me—as long as you don't have a large collection. A somewhat shorter way to write could be: Product.all.each &:to_param See here. This kind of stuff could go into the Wiki. |
@hakanensari |
I still don't see this documented in the README or in the Wiki. Product.all.each do |product|
product.send(:set_slug)
product.save
end Is this the right way to do it? |
.all.each &:to_param didn't work for me. This is what worked: Product.all.each do |product| |
I had a hard time working out how add a
slug
retrospectively. Given the model:I initially tried calling
save
but this doesn't generate it.The only way I could find to create slugs for existing documents was:
This seems a bit hacky... Is there a better way to do this?
If so could you add it to the README?
If this is the only way, could you expose a public method to generating slugs on existing documents?
The text was updated successfully, but these errors were encountered: