title: Rails: how to redirect to "show" action of nested resource in a "create" action?
body: <p>Hi I currently have 3 models: user, album, photo. I've made registration, but not login/sessions yet, since I am trying to have the album/photo creation finished first. However, when I create an album the URL changes from</p>
  
  <p><code>http://localhost:3000/users/13/albums/new</code> (no problem)</p>
  
  <p>to</p>
  
  <p><code>http://localhost:3000/albums/76/photos/76</code> (problem)</p>
  
  <p>the issues here are: 
  1. the user_id disappears from the url.
  2. it's sending me to the wrong url. As you can see below, I am redirecting to [@user, @album]. Isn't that supposed to be the show action of the albums controller? I wanted something like /users/13/albums/1 as the url. Instead, it's sending me to <code>photos#show</code>.
  3. even though it's the wrong link, why are the album id and the photo id are always the same? 76/76 77/77 etc... I don't know where that is coming from..</p>
  
  <p>here are my files:</p>
  
  <p>album controller</p>
  
  <pre><code>def show
    @user = User.find(params[:user_id])
    @album = @user.albums.find(params[:id])
    @photo = @album.photos.build(params[:photo])
    respond_to do |format|
      if @album.save
        format.html { redirect_to album_photo_path(@album), notice: 'Album was successfully created.' }
        format.json { render json: @album, status: :created, location: @album}
      else
        format.html { render action: "new" }
        format.json { render json: @album.errors, status: :unprocessable_entity }
      end
    end
  end
  
  def update
  end
  
  def edit
  end
  
  def create
    @user = User.find(params[:user_id])
    @album = @user.albums.build(params[:album])
    respond_to do |format|
      if @user.save
        format.html { redirect_to [@user, @album], notice: 'Album was successfully created.' }
        format.json { render json: @album, status: :created, location: @album}
      else
        format.html { render action: "new" }
        format.json { render json: @album.errors, status: :unprocessable_entity }
      end
    end 
  end
  </code></pre>
  
  <p>albums/new.html.erb</p>
  
  <pre><code>&lt;%= form_for (@album), url: user_albums_path, :html =&gt; { :id =&gt; "uploadform", :multipart =&gt; true } do |f| %&gt;
  
  
  
  &lt;div&gt;
      &lt;%= f.label :name %&gt;
      &lt;%= f.text_field :name %&gt;
  
  
      &lt;%= f.label :description %&gt;
      &lt;%= f.text_area :description %&gt;
  
      &lt;br&gt;
  
      &lt;%=f.submit %&gt;
  &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>config/routes</p>
  
  <pre><code>Pholder::Application.routes.draw do
  resources :users do
    resources :albums 
  end
  
  resources :albums do
    resources :photos
  end
  </code></pre>
  
  <p>let me know if you need anymore files.</p>