title: Finding a Model with Params other than ID
body: <p>I'm using Rails 4 with strong parameters to try to find a user by a parameter called "provider_id".
  The hope is that I'll be able to make a call with my API to a URL such as:</p>
  
  <p>url.com/api/v1/user?provider=facebook?provider_id=12345</p>
  
  <p>My routes are as follows: <strong>routes.rb</strong></p>
  
  <pre><code>namespace :api do
      namespace :v1 do
          resources :users
          match '/:provider/:provider_id', to: 'users#find_by_provider', via: 'get'
      end
  end
  </code></pre>
  
  <p>My Strong parameters are: </p>
  
  <pre><code>def user_params
      params.require(:user).permit(:name, :age, :location, :provider, :provider_id) if params[:user]
  end
  </code></pre>
  
  <p>My Function is:</p>
  
  <pre><code>def find_by_provider
      @user = User.find(params[:provider_id])
  
      respond_to do |format|
          format.json { render json: @user }
      end
  end
  </code></pre>
  
  <p>Currently, I'm testing with:
  url.com/api/v1/facebook/12345
  and it is returning:</p>
  
  <pre><code>"{"provider"=&gt;"facebook",
  "provider_id"=&gt;"12345"}"
  </code></pre>
  
  <p>which is good! But I now get the error: "Couldn't find User with id=12345"</p>
  
  <p>Also, somewhat related: occasionally I receive an error that says "param not found: user".</p>
  
  <p>Any suggestions? Thanks!</p>