Nested Rotues

Hi,

I am making a survey app.

The user takes the survey and I’m saving it fine.

But what i want next is to redirect the user to /surveys/1/results
after completion.

I have tried the following in my routes file:

Rails.application.routes.draw do
resources :surveys do
match ‘results’ => ‘results#index’
end
resources :survey_answers
end

And in my controller i tried:
redirect_to survey_results_path(@survey)

but im getting:
No route matches {:controller=>“results”}

Any help?

What’s the structure of your model? survey => answers, or survey =>
results?

Use ‘rake routes’ to give you a sense of what route helpers you can
use.

Yan

Rails.application.routes.draw do
resources :surveys do
match ‘results’ => ‘results#index’
end
resources :surveys do
resources :results
end
resources :survey_answers
end

And in my controller i tried:
redirect_to survey_results_path(@survey)

but im getting:
No route matches {:controller=>“results”}

You need a results controller here.