2016-11-09 36 views
0

我有一個複雜的嚮導,我想根據他們的條目路由到窗體的用戶。Rails 4 +邪惡:使用參數來路由

我列出的步驟如下:

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的info屬性。 我猜你必須重寫你的行動那樣:

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不包含:癌症的關鍵,如果使用Ruby哈希的情況下,你必須設置關鍵像這樣:

@remote[:cancer] = true 
return jump_to(:cancer) if @remote[:cancer] 
return render_wizard info