2016-11-09 12 views
0

私は少し複雑なウィザードを持っています。ユーザーにフォームに基づいてユーザーをルーティングしたいと思います。Rails 4 + Wicked:パラメータを使って経路を設定する

次のように私はステップをリストした:

steps :weight_loss_history, :health_conditions, :cancer, :weight_mindset, :diabetes, :diet_information, :heart, :food_intake 

を...そして、次のように私の更新とルーティングの機能は以下のとおりです。

def update 
    @remote = current_remote 
    params[:remote][:step] = step 
    atts = Remote.fix_attributes(params[:remote]) 
    @remote.attributes = atts # equal to large hash of params 
    find_route(@remote) 
end 

def find_route(info) 
    if info[:cancer] 
     puts "cancer..." # I never see this in the console 
     jump_to(:cancer) 
    else 
     render_wizard info 
    end 
end 

誰もがルートに邪悪を使用しての良い実装を持っていますユーザーは選択肢に基づいていますか?

答えて

0

ここでの問題は、find_routeに渡す情報属性にあります。がんキーをとルビーのハッシュを使用した場合場合は、キーを設定する必要があります。

def update 
    @remote = current_remote 
    params[:remote][:step] = step 
    atts = Remote.fix_attributes(params[:remote]) 
    @remote.attributes = atts # equal to large hash of params 
    return jump_to(:cancer) if step == :cancer 
    return render_wizard info 
end 

そう私は推測する手順からプッシュする場合は@Remoteが含まれていないこと: 私はあなたがそのようなあなたの行動を書き換える必要があることを推測しますそのように:

@remote[:cancer] = true 
return jump_to(:cancer) if @remote[:cancer] 
return render_wizard info 
関連する問題