I'm following A Wicked exampe to build my wizard, except I am creating the model in a dedicated controller first then on save redirecting to the steps controller but I'm getting a routing error saying:
No route matches {:action=>"show", :controller=>"needs_personals/steps"}
The redirect code looks like this:
redirect_to needs_personal_step_path, :needs_personal_id => @needsPersonal.id
I used needs_personal_step_path
because my rake routes
outputs this:
needs_personal_steps GET /needs_personals/:needs_personal_id/steps(.:format) needs_personals/steps#index
POST /needs_personals/:needs_personal_id/steps(.:format) needs_personals/steps#create
new_needs_personal_step GET /needs_personals/:needs_personal_id/steps/new(.:format) needs_personals/steps#new
edit_needs_personal_step GET /needs_personals/:needs_personal_id/steps/:id/edit(.:format) needs_personals/steps#edit
needs_personal_step GET /needs_personals/:needs_personal_id/steps/:id(.:format) needs_personals/steps#show
PUT /needs_personals/:needs_personal_id/steps/:id(.:format) needs_personals/steps#update
DELETE /needs_personals/:needs_personal_id/steps/:id(.:format) needs_personals/steps#destroy
In the routes file I have this:
resources :needs_personals do
resources :steps, controller: 'needs_personals/steps'
end
If I type in a path directing into the browser it works /needs_personals/90/steps
Thanks.
Update 29th Sept, 2012
I believe I have worked out why this is doing it and have implemented a work around. I think it is happening because of a confusion with the id param. Despite passing needs_personal_id
it is seems to be treating the id as the last param of the link instead of the middle id.
My work around is just to point it at the actual string url:
redirect_to "/needs_personals/#{@needsPersonal.id}/steps"
This works well. Though would love to know how to do it with the right path.