2013-11-27 29 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