Rails - couldn't find IT with "ID"=
<p>I'm trying to build a software for small banks, which involves deals, pools (of banks) and credit facilities. For information, a facility belongs to a pool of banks, which belongs to a deal.</p>

<p>Below is my issue when i try to create a "facility" : </p>

<pre><code>Couldn't find Pool with 'id'=
</code></pre>

<p>I have 3 models : Deal, Pool, Facility</p>

<pre><code>class Deal &lt; ActiveRecord::Base
  has_many :banks
  has_many :pools, :dependent =&gt; :destroy
end

class Pool &lt; ActiveRecord::Base
  belongs_to :deal
end

class Facility &lt; ActiveRecord::Base
  belongs_to :pool
end
</code></pre>

<p>Below is my Facilitys controller :</p>

<pre><code>class FacilitysController &lt; ApplicationController
  before_action :authenticate_user!
  before_action :set_pool
  before_action :set_facility, only: [:show, :edit, :update, :destroy]

  def new
    @pool = Pool.find(params[:id])
    @facility = Facility.new
  end

  def edit
    @facility = Facility.find(params[:id])
  end

  def create
    @facility = Facility.new(facilitys_params)

    if @facility.save
      redirect_to root_path, notice: "Facility successfully created!"
    else
      render "New"
    end
  end

  def show
    @facility = Facility.find(params[:id])
    @facility.pool_id = @pool.id
  end

  def update
    @facility.update(facilitys_params)
    if @facility.update(facilitys_params)
      redirect_to deal_facility_url(@pool, @facility), notice: "Facility successfully updated!"
    else
      render :edit
    end
  end

  def destroy
    @facility.destroy
  end

  private

  def set_pool
    @pool = Pool.find(params[:id])
  end

  def set_facility
    @facility = Facility.find(params[:id])
  end

  def facilitys_params
    params.require(:facility).permit(:name)
  end
end
</code></pre>

<p>My routes are</p>

<pre><code>resources :deals do
resources :pools, except: [:index] do
    resources :facilitys, except: [:index]
end
end
</code></pre>