0

私のルートは次のようになります

  resources :stores, :except => [:destroy] do
    resources :toys, :member => {:destroy => :delete}
  end

私のオブジェクトコントローラーの仕様は次のようになります

require 'spec_helper'

describe ToysController do

    describe "GET index" do
        it "assigns all toys as @toys" do
          toy11 = Factory(:toy, :is_shiny => true)
          toy12 = Factory(:toy,:is_shiny => false)
          get :index
          assigns(:toys).should eq([toy12,toy11 ])
        end
      end
    end
end

次のエラーが発生しました

 Failure/Error: get :index
 ActionController::RoutingError:
 No route matches {:controller=>"toys"}

おもちゃのリソースはストア リソースの下にネストされているため、toys_path ルートを取得できないため、仕様が失敗していると思います。

どうすれば仕様に合格できますか?

ありがとう

4

1 に答える 1

0

エラーは、store_id を tyos インデックスに送信していないことが原因です。送ったかな

:store_id => @store.id in get :index

それは過ぎただろう。

于 2011-09-27T16:59:57.870 に答える