我正在申請我們有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