2011-08-23 35 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 
相关问题