Ich habe diese Route:Keine Route Spiel in Controller-Spezifikation für meine komplexe Route
resources :items, path: 'feed', only: [:index], defaults: { variant: :feed }
, die in der api und v1 Namespaces verschachtelt ist. (Die Parameter request_source stammt aus dem Api-Namespace).
Ich möchte die Indexaktion in meiner Controller-Spezifikation testen. Ich habe versucht:
get :feed, community_id: community.id, :request_source=>"api"
nicht funktioniert, und so tut:
get :index, community_id: community.id, :request_source=>"api", variant: 'feed'
sagen:
ActionController::RoutingError:
No route matches {:community_id=>"14", :request_source=>"api", :variant=>"feed", :controller=>"api/v1/items"}
------- -------- EDIT -
Der Grund, warum ich die Variante verwenden möchte, um die Parameter an den Controller zu senden, ist, weil ich alle diese Routen habe:
resources :items, path: 'feed', only: [:index], defaults: { variant: 'feed' }
resources :items, path: 'popular', only: [:index], defaults: { variant: 'popular' }
Dann in ItemsController, ich habe ein vor Filter "get_items" für den Index Aktion wich tut:
def get_items
if params[:variant] == 'feed'
....
elsif params[:variant] == 'popular'
....
end
Was ist der Backtrace auf die Ausnahme? –