このルーティングエラーを解決しようとして自殺しています。
背景情報: Ryan Bates の Rails Cast on Wicked Wizard Forms を使用して、複数ステップのフォームを作成しています。ルーティング エラーが発生します。
No route matches {:controller=>"user_steps", :action=>"show", :id=>nil}
明らかにuser.id
、次のビューに渡されていません - これを解決する方法はありますか?
ユーザーコントローラーの作成:
def create
@user = User.new(params[:user])
respond_to do |format|
if @user.save
session[:user_id] = @user.id
format.html { redirect_to user_steps_path(@user) }
#format.html { redirect_to @user, notice: 'User was successfully created.' }#
format.json { render json: @user, status: :created, location: @user }
else
format.html { render action: "new" }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
ユーザー ステップ コントローラー (Wicked 用)
class UserStepsController < ApplicationController
include Wicked::Wizard
steps :gender, :items, :brands, :final
def show
render_wizard
end
def update
@user.update_attributes(params[:user])
render_wizard @user
end
end
ルート:
Store::Application.routes.draw do
resources :likes
resources :categories
resources :user_steps
match "user_steps/gender", to: "user_steps#gender", via: "post"
resources :users
users_steps/gender.html.erb
<%= form_for :user, url: wizard_path do |f| %>
<div class="container" align="center">
<div class="div2" align="center">
<h2 align="center"> You are a ...</h2>
<div class="container" align="center">
<div class="row" align="center">
<div class="span6">
<h9>Guy</h9>
<label for="user_gender_guy"><img src="http://i.imgur.com/bpIMo.png" class="new" width="200" height="500"></label>
<input checked="checked" id="user_gender_guy" name="user[gender]" type="radio" value="Guy" />
</div>
<div class="span6">
<h9>Girl</h9>
<label for="user_gender_girl"><img src="http://i.imgur.com/xpA1S.png" class="new" width="200" height="500"></label>
<input checked="checked" id="user_gender_girl" name="user[gender]" type="radio" value="Girl" />
</div>
</div>
</div>
</div>
</div>
<%= f.submit "Next" %>
<% end %>
レーキ ルート:
user_steps GET /user_steps(.:format) user_steps#index
POST /user_steps(.:format) user_steps#create
new_user_step GET /user_steps/new(.:format) user_steps#new
edit_user_step GET /user_steps/:id/edit(.:format) user_steps#edit
user_step GET /user_steps/:id(.:format) user_steps#show
PUT /user_steps/:id(.:format) user_steps#update
DELETE /user_steps/:id(.:format) user_steps#destroy
user_steps_gender POST /user_steps/gender(.:format) user_steps#gender