title: Rails 4 + Friendly_id gem: How to generate slug with a specific string?
body: <p>I'm building an app that uses the globalize gem. I'm trying to add the Friendly ID gem for permalinks.</p>
  
  <p>My <code>Product</code> table doesn't actually have a <code>name</code> column. The <code>name</code> column is stored in <code>Product::Translation</code>, so I can't use the <code>friendly_id :name, use: :slugged</code> set up that they recommend in the github page.</p>
  
  <p>I want to set the permalink to the <code>name</code> attribute of the english translation. This is what I have so far:</p>
  
  <pre><code>before_save :update_slug
  
  def update_slug
    english_translation = translations.find { |t| t.locale == :en }
    self.slug = english_translation.name if english_translation
  end
  </code></pre>
  
  <p>However, this doesn't convert the english_translation.name variable to a parameter friendly format. If I have the name as <code>something sdfsdfs sdfsf</code>, the slug will be the same and that would break things since the path would be <code>/products/something sdfsdfs sdfsf</code> with all the spaces. </p>
  
  <p>Is there a method I can run to convert a string into slug format? Something like:</p>
  
  <pre><code>before_save :update_slug
  
  def update_slug
    english_translation = translations.find { |t| t.locale == :en }
    self.slug = slugify(english_translation.name)
  end
  </code></pre>
  
  <p>I need a method that I can run manually with a parameter to generate the slug.</p>