2016-11-09 5 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 
관련 문제