title: Rails 4 - "Create" action in controller when it's a nested route
body: <p>I have a User model that has_many Photos (another model).  In the routes.rb file it's photos is a nested resource of user.  So, I have a form_for that uploads to the controller #create action.  I'm having trouble saving the photo into the database under the user.  How can I do this?  It says it saves correctly, because it redirects, but then it doesn't show that it has a photo (I also used the console to check not just my view).  What am I doing wrong?</p>
  
  <pre><code>class PhotosController &lt; ApplicationController
    def new
      @photo = Photo.new(:user_id =&gt; params[:user_id])
    end
  
    def create
      byebug
      @photo = Photo.new(params[:user_id])
      if @photo.save
        flash[:notice] = "Successfully added photo."
        redirect_to new_user_photo_path
      else
        render :action =&gt; 'new'
      end
    end
  end
  </code></pre>
  
  <p>EDIT----------</p>
  
  <p>Adding in the form_for that gets us to the #create action.  Hope this helps :) I've been reading more about this, and I'm still not sure what to do to fix.</p>
  
  <pre><code>&lt;%= form_for @photo, :url =&gt; user_photos_path(current_user.id, @photo), :html =&gt; {:multipart =&gt; true} do |f| %&gt;
    &lt;div class="form-group"&gt;
      &lt;%= f.file_field :image %&gt;
    &lt;/div&gt;
    &lt;%= f.submit 'Upload', class: 'btn btn-success' %&gt;
    &amp;nbsp;or
    &lt;%= link_to 'Cancel', users_path %&gt;
  &lt;% end %&gt;
  </code></pre>