title: No route matches {:controller=>"stocks", :action=>"create"} RSpec Rails 3
body: <p>I don't understand why I'm getting this error message when I run RSpec: </p>
  
  <pre><code>Failure/Error: post :create
   ActionController::RoutingError:
     No route matches {:controller=&gt;"stocks", :action=&gt;"create"}
  </code></pre>
  
  <p>The controller stocks exists, the action create exists, and the route it should be using is this: </p>
  
  <pre><code>match 'stocks/:user_id' =&gt; 'stocks#create', :via =&gt; :post, :as =&gt; :query
  </code></pre>
  
  <p>Route File: </p>
  
  <pre><code>FruthScreener::Application.routes.draw do
  root :to =&gt; 'stocks#index' # add user_id
  match 'stocks/:user_id' =&gt; 'stocks#create', :via =&gt; :post, :as =&gt; :query
  match 'stocks/:user_id' =&gt; 'stocks#destroy', :via =&gt; :delete, :as =&gt; :reset
  match 'stocks/:user_id/update' =&gt; "stocks#update_index", :via =&gt; :post
  </code></pre>
  
  <p>Stock Controller: (Yes, this will be DRYed up)</p>
  
  <pre><code>class StocksController &lt; ApplicationController
  def index
      @user = User.create
      @user_id_num = @user.id
      @user.stocks = Stock.all
      @user.save
      selected_user_stocks = (UserStock.where("user_id = #{@user_id_num} AND selected = true")).take(25)
      @stocks = UserStock.convert_to_stocks(selected_user_stocks)
      @pages = Pagination.determine_num_pages(@user.stocks) 
  end
  
  def update_index
      @user_id_num = params[:user_id]
      @user = User.find(@user_id_num)
      selected_user_stocks = UserStock.where("user_id = #{@user_id_num} AND selected = true")
      @stocks = UserStock.convert_to_stocks(selected_user_stocks)
      @pages = Pagination.determine_num_pages(@stocks)
      @stocks = Stock.display(@stocks, params[:pageNumber].to_i)
      render partial: 'stock_data'
  end
  
  def create
      UserStock.eliminate_stocks(params) # thinking it's like "creating" a new batch of stocks
      @user_id_num = params[:user_id]
      @user = User.find(@user_id_num)
      selected_user_stocks = UserStock.where("user_id = #{@user_id_num} AND selected = true")
      @stocks = UserStock.convert_to_stocks(selected_user_stocks)
      @pages = Pagination.determine_num_pages(@stocks) 
      @stocks = Stock.display(@stocks, 1)
      render partial: 'stock_data'
  end
  
  def destroy
      stocks_to_reset = UserStock.where("user_id = #{params[:user_id]}")
      stocks_to_reset.each do |user_stock|
          user_stock.selected = true
          user_stock.save
      end
      @user_id_num = params[:user_id]
      @user = User.find(@user_id_num)
       selected_user_stocks = UserStock.where("user_id = #{@user_id_num} AND selected = true")
      @stocks = UserStock.convert_to_stocks(selected_user_stocks)
      @pages = Pagination.determine_num_pages(@stocks) 
      @stocks = Stock.display(@stocks, 1)
      render partial: 'stock_data'
  end
  
  
  end
  </code></pre>
  
  <p>Stock Controller Spec: (test at bottom is failing)</p>
  
  <pre><code>require 'spec_helper'
  
  RSpec.configure do |config|
    config.infer_spec_type_from_file_location!
  end
  
  describe StocksController do
  
    context "index" do 
      before do 
          @user_count = User.all.count 
          @stock_count = Stock.all.count
          get :index
      end
  
      it "should create a new user" do
          expect(User.all.count).to eq(@user_count + 1)
      end
  
      it "should associate all stocks with the user" do
          expect(User.last.stocks.count).to eq(@stock_count)
      end
    end
  
    context "create" do # investigate why this isn't working...
      it "should render the stock_list partial" do
          user = User.create
          post :create
          response.should render_template(partial: "stock_list")
      end
    end
  
  end
  </code></pre>
  
  <p>Thanks!!</p>