title: Friendly URL Question, with a Twist
body: <p>I have a user model and a profile model.</p>
  
  <p><code>user has_one :profile</code>
  <code>profile belongs_to :user</code></p>
  
  <p>Because of this relationship, I pull up my profiles by calling the user id.  So my urls look like this: website.com/users/[user_id]/profile</p>
  
  <p>I'm not sure if there's a solution to my problem. Here it is:
  I would like to display SEO friendly urls.  I'm looking at using <code>friendly_id</code> for this.  But, our profiles are for businesses, and it's the business name that we want to put in the url.  The problem is that our user model intentionally does not ask for the business name, and it's the <code>user_id</code> that gets displayed in the url currently.  </p>
  
  <p>Is there a way to grab the business name from the profile model (i.e. @profile.name), and use it to populate the [user_id] part of the url?</p>
  
  <p>UPDATE: I've set up the friendly_id gem and it seems like this could work.  In my profile model, I have this: <code>has_friendly_id :name, :use_slug =&gt; true</code></p>
  
  <p>When I updated a profile, <code>friendly_id</code> did slugify the url by putting the business name from the profile into the <code>user_id</code> part of the url.  But, of course, this threw an exception.</p>
  
  <p>So if the the business name in the profile model is Mike's Bar, the url now says /users/mike-s-bar/profile.  The exception says this: Couldn't find User with <code>ID=mike-s-bar.</code></p>
  
  <p>Here's my profiles controller:</p>
  
  <pre><code>def show
    @user = User.find(:all)
    @profile = User.find(params[:user_id])
  end  
  </code></pre>
  
  <p>Is there a way to make this work?</p>