title: Rspec Create Post with nested parameters
body: <p>I'm trying to fix some tests that I have written in my comments controller. As of now, with my current tests I get this error:</p>
  
  <pre><code>Failure/Error: @outlet = Outlet.find(params[:comment][:outlet_id])
  
   ActiveRecord::RecordNotFound:
     Couldn't find Outlet with 'id'=
  </code></pre>
  
  <p>Here is an example of some of the tests</p>
  
  <pre><code>describe '#create' do
      context 'with valid attributes' do 
          before :each do
              @outlet = FactoryGirl.create(:outlet)
              @user = FactoryGirl.create(:user)
              @comment_params =  FactoryGirl.attributes_for(:comment)
          end
  
          let(:create) { post :create, params: { outlet_id: @outlet.id, user_id: @user.id, comment: @comment_params } }
  
          it "creates new comment" do
              expect { create }.to change { Comment.count }.by(1)
          end
  
          it "increases the post comment count by 1" do
              expect { create }.to change { @outlet.comments.count }.by(1)
          end
  
          it "increases user comment count by 1" do
              expect { create }.to change { @user.comments.count }.by(1)
          end
      end
  end
  </code></pre>
  
  <p>I'm pretty sure this is happening because of my create statement in my tests</p>
  
  <pre><code>let(:create) { post :create, params: { outlet_id: @outlet.id, user_id: @user.id, comment: @comment_params } }
  </code></pre>
  
  <p>Here is my comments controller create action</p>
  
  <pre><code>def create
      @outlet = Outlet.find(params[:comment][:outlet_id])
      @comment = @outlet.comments.build(comment_params)
      @comment.user_id = current_user.id
  
  
      if @comment.save
          redirect_to(@outlet)
      end
  end
  </code></pre>
  
  <p>I'm pretty sure it is not working, because the outlet_id that it is looking for is a nested parameter inside of the comments parameter. How would I fix my rspec test to have it look for a nested parameter?</p>