2013-11-27 30 views
0

我正在申请我们有usersprojects。每个用户都可以管理一个项目。无论如何,我希望用户在sign up处定义/选择他们的项目。用户和项目与has many through关联关联。收集选择与设计(Rails 3.2)

我已将此代码加入注册表单,使用form_for

<%= f.collection_select :project_ids, @projects, :id, :project_name, {}, { :multiple => false } %> 

在发展:它完美!

制作中:它破裂了,我得到了“我们很抱歉,但出了点问题。”从Heroku和用户不会创建。

日志没有给出失败原因。

2013-11-27T20:40:11.087603+00:00 app[web.1]: Started POST "/users" for 66.44.22.241 at  2013-11-27 20:40:11 +0000 
2013-11-27T20:40:13.443773+00:00 app[web.1]: 
2013-11-27T20:40:13.443773+00:00 app[web.1]: Sent mail to [email protected] (894ms) 
2013-11-27T20:40:13.935915+00:00 app[web.1]: Started GET "/" for 66.44.22.241 at 2013-11-27 20:40:13 +0000 

当我删除关联属性时,登录工作,并且日志看起来是相同的(对我来说至少)。

2013-11-27T20:45:21.122286+00:00 app[web.1]: Started POST "/users" for 66.44.22.241 at 2013-11-27 20:45:21 +0000 
2013-11-27T20:45:22.402149+00:00 app[web.1]: 
2013-11-27T20:45:22.402149+00:00 app[web.1]: Sent mail to [email protected] (714ms) 
2013-11-27T20:45:23.116820+00:00 app[web.1]: Started GET "/" for 66.44.22.241 at 2013-11-27 20:45:23 +0000 

我色器件覆盖:

def create 
@user = User.new(params[:user]) 
resource = @user 

if resource.save 
    yield resource if block_given? 
    if resource.active_for_authentication? 
    flash[:notice] = "Signed up successsfully." 
    sign_up(resource_name, resource) 
    respond_with resource, :location => after_sign_up_path_for(resource) 
    else 
    flash[:notice] = "Signed up successsfully." 
    expire_data_after_sign_in! 
    respond_with resource, :location => after_inactive_sign_up_path_for(resource) 
    end 
else 
    clean_up_passwords resource 
    respond_with resource 
end 
end 
+0

运行“heroku logs”时发现的错误消息是 – davidfurber

+0

添加到帖子,谢谢 – miler350

回答

1

的可能的问题就是图谋已发送的电子邮件后,色器件之一回滚节约交易后到来的after_save的。如果用户模型看到有什么有趣的东西,那么将设​​计语句移到底部。

+0

错误在这一行:'respond_with resource' 问题是没有收到错误,它是用户是没有被创建。我将respond_to资源更改为'redirect_to root_path',即停止应用程序发出错误,但不创建用户。 – miler350

+0

我更改了heroku日志输出以显示发生的情况。当我删除关联属性时,我将添加另一个成功的标志。 – miler350

+0

所以这是说它发送了一封电子邮件给用户,但实际上并没有创建用户? – davidfurber