0

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.

Jaijaz
  • 134
  • 1
  • 12

1 Answers1

1

I think this is what you are looking for:

redirect_to needs_personals_steps_path(@needsPersonal.id, :first_step)

where :first_step is the symbol to your first wizard step.

madhermit
  • 367
  • 3
  • 11
  • Thanks. Your answer was almost correct. So I'm going to make it as right and mention that it is in fact `redirect_to needs_personal_steps_path(@needsPersonal.id, :first_step)` Guessing because we are dealing with a singular needsPersonal model and not all. Thanks again for getting me on the right path, so to speak ;) – Jaijaz Oct 06 '12 at 07:46
  • Came back to look at this and noticed a typo in my comment. It is in fact: `redirect_to needs_personal_step_path(@needsPersonal.id, :first_step)` – Jaijaz Oct 27 '12 at 11:01