我的路线.rb
namespace :magazine do
resources :pages do
resources :articles do
resources :comments
end
end
end
在为 Comments 编写控制器规范时:
describe "GET 'index'" do
before(:each) do
@user = FactoryGirl.create(:user)
@page = FactoryGirl.build(:page)
@page.creator = @user
@page.save
@article = FactoryGirl.create(:article)
@comment_attributes = FactoryGirl.attributes_for(:comment, :article_id => @article )
end
it "populates an array of materials" do
get :index, ??
#response.should be_success
assigns(:comments)
end
it "renders the :index view" do
get :index, ??
response.should render_template("index")
end
end
知道如何提供页面和文章参考以获取 :index 吗?如果我给 :get :index, :article_id => @article.id
我得到的错误如下:
Failure/Error: get :index, :article_id => @article.id
ActionController::RoutingError:
No route matches {:article_id =>"3", :controller=>"magazine/comments"}