2011-08-23 65 views
1

我有2個控制器:ProjectsUsers。兩種模式根本沒有關係。Rails 3 - Redirect_to /渲染另一個控制器

當我創建一個新的Project我要保存新project後重定向到new User path,但我所有的嘗試給像缺少模板或類似的東西誤差修改。

我該如何得到這個工作?

EDITED

我在Projects控制器創建方法:

DEF創建

@project = Project.new(PARAMS [:項目])

respond_to do |format| 
    if @project.save  
    format.html { render (new_user_registration_path) } 

    else 
    format.html { render :action => "new" } 
    format.xml { render :xml => @project.errors, :status => :unprocessable_entity } 
    end 
end 

+0

你可以發佈你正在嘗試使用的代碼? –

+0

添加stacktrace到你的問題 – lucapette

回答

3

你不想渲染new_user_registration_path,要redirect_to的new_user_registration_path

0

您必須使用redirect_to的,而不是渲染:

redirect_to new_user_registration_path 

respond_to do |format| 
    if @project.save  
    format.html { redirect_to new_user_registration_path } 
    else 
    format.html { render :action => "new" } 
    format.xml { render :xml => @project.errors, :status => :unprocessable_entity } 
    end 
end 
相關問題