Как я могу связать свои маршруты, чтобы спецификация прошла? Я прочитал здесь http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/
Спецификация
require 'spec_helper'
describe ConversationMembersController do
describe "routing" do
it "recognizes and generates #index" do
{ :get => "/conversations/123/members" }.should route_to(:controller => "conversation_members", :action => "index", :conversation_id=>"123")
end
end
end
Сбой спецификации
ConversationMembersController routing recognizes and generates #index
Failure/Error: { :get => "/conversations/123/members" }.should route_to(:controller => "conversation_members", :action => "index", :conversation_id=>"123")
The recognized options <{"action"=>"123", "id"=>"members", "controller"=>"conversations"}> did not match <{"conversation_id"=>"123",
"action"=>"index",
"controller"=>"conversation_members"}>, difference: <{"conversation_id"=>"123",
"action"=>"index",
"id"=>"members",
"controller"=>"conversation_members"}>
Маршруты
resources :conversations, :except => [:edit] do
resources :conversation_members, :as => "members", :except => [:show, :edit, :update, :destroy] do
collection do
delete :leave
end
end
Выход rake routes | grep conversation_members
52: leave_conversation_members DELETE /conversations/:conversation_id/conversation_members/leave(.:format) {:action=>"leave", :controller=>"conversation_members"}
53: conversation_members GET /conversations/:conversation_id/conversation_members(.:format) {:action=>"index", :controller=>"conversation_members"}
54: POST /conversations/:conversation_id/conversation_members(.:format) {:action=>"create", :controller=>"conversation_members"}
55: new_conversation_member GET /conversations/:conversation_id/conversation_members/new(.:format) {:action=>"new", :controller=>"conversation_members"}