Skip to content
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

initialize_urls not updating slugs as expected. #184

Open
sergiotapia opened this issue Feb 11, 2016 · 2 comments
Open

initialize_urls not updating slugs as expected. #184

sergiotapia opened this issue Feb 11, 2016 · 2 comments

Comments

@sergiotapia
Copy link

I have a Company model, with fields name and slug:

class Company < ActiveRecord::Base
  acts_as_url :name, url_attribute: :slug
end

For new records, the gem converts asian characters to phonetic letters fine. Now I'm just trying to do the same for all of the existing records in our database.

For example here's one existing record we want to fix the slug for:

[1] pry(main)> Company.last.name
=> "Working 你好"

[2] pry(main)> Company.last.slug
=> "----"

After running the initialize_urls method, I expect the slug to be updated with the phonetic letters, but they don't change.

Here's the rake task that starts off the process:

# Rake task that iterates through all of the Companies in the database
# and regenerates their slug values from their name attribute.
task regenerate_company_slugs: :environment do
  Company.initialize_urls
end
@fauxparse
Copy link
Contributor

URLs will only be updated when the slug is nil.

@rsl
Copy link
Owner

rsl commented Jan 18, 2017

what do you think about having another method do this functionality. initialize [to me] is the right term here as it's [to me] stating it will set one if not set. thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants