我正在申请我们有users
和projects
。每个用户都可以管理一个项目。无论如何,我希望用户在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
运行“heroku logs”时发现的错误消息是 – davidfurber
添加到帖子,谢谢 – miler350