I have this route:
resources :items, path: 'feed', only: [:index], defaults: { variant: :feed }
which is nested in the api and v1 namespaces. (request_source parameters come from the Api namespace).
I want to check the effect of the index in the specification of my controller. I tried:
get :feed, community_id: community.id, :request_source=>"api"
does not work, and so:
get :index, community_id: community.id, :request_source=>"api", variant: 'feed'
saying:
ActionController::RoutingError:
No route matches {:community_id=>"14", :request_source=>"api", :variant=>"feed", :controller=>"api/v1/items"}
------- EDIT ---------
The reason I want to use the option of sending parameters to the controller is because I have all these routes:
resources :items, path: 'feed', only: [:index], defaults: { variant: 'feed' }
resources :items, path: 'popular', only: [:index], defaults: { variant: 'popular' }
Then in the ItemsController, I have a filter before get_items for the index action, which does:
def get_items
if params[:variant] == 'feed'
....
elsif params[:variant] == 'popular'
....
end