title: Rails friendly_id gem for pretty url
body: <p>Is there a way to make friendly_id dynamic, something like the below, so that depending on an attribute in my user model (next_language) I can adjust how the url's look. I'm using devise. Ideally I would like the controller to handle this logic but can't think of how to do it. The below errors out because the lang model has no idea about current_user.</p>
  
  <p>lang model:</p>
  
  <pre><code>class Lang &lt; ActiveRecord::Base
  
     if current_user.next_language == "English"
      extend FriendlyId
      friendly_id :english
     end
  
     if current_user.next_language == "Spanish"
      extend FriendlyId
      friendly_id :spanish
     end
  
  end
  </code></pre>
  
  <p>here's a sample user record generated when somebody signs up:</p>
  
  <pre><code>User.find(5)
    User Load (0.9ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 5]]
   =&gt; #&lt;User id: 5, email: "mtcrts71@gmail.com", encrypted_password: "$2a$10$ZRBXllLt7lmU7YUuCV62.OzlaaleE/XnV4yzQwJtSN9f...", confirmation_token: nil, confirmed_at: "2014-07-19 17:48:29", confirmation_sent_at: "2014-07-19 17:46:15", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2014-07-19 17:48:29", last_sign_in_at: "2014-07-19 17:48:29", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", created_at: "2014-07-19 17:46:15", updated_at: "2014-07-19 17:48:29", next_language: "English", admin: false, unconfirmed_email: nil, bookmark: 1, bookmark2: 0, qscore: 0, quiz_flag: 0, total_quiz: 0, natives_language: "Spanish", fqscore: nil&gt;
  </code></pre>
  
  <p>sample lang record:</p>
  
  <pre><code>Lang.find(1)
    Lang Load (0.8ms)  SELECT "langs".* FROM "langs" WHERE "langs"."id" = $1 LIMIT 1  [["id", 1]]
   =&gt; #&lt;Lang id: 1, english: "be", english_to_spanish: "ser", spanish: "una", spanish_to_english: "a", created_at: "2014-07-11 01:30:53", updated_at: "2014-07-11 01:30:53"&gt; 
  </code></pre>
  
  <p>So based on the above, if the user is learning Spanish the url might look like:</p>
  
  <pre><code>http://localhost:3000/langs/una
  </code></pre>
  
  <p>or English:</p>
  
  <pre><code>http://localhost:3000/langs/be
  </code></pre>
  
  <p><strong><em>Edit to include controller and view code:</em></strong></p>
  
  <p>controller:</p>
  
  <pre><code>class StaticPagesController &lt; ApplicationController
  
    def home
      if user_signed_in?
        @placemark = Lang.find(current_user.bookmark)
      end
    end
  end
  </code></pre>
  
  <p>relevant view code:</p>
  
  <pre><code>&lt;%= link_to "Continue Learning!", lang_path(@placemark), class: "btn btn-large btn-primary"%&gt;
  </code></pre>