在我通過Facebook和Google實施認證之前,我的應用程序中的所有內容都正常工作。「Web應用程序無法啓動。未初始化的常量用戶(NameError)」
該應用程序託管在Amazon EC2中,我使用Capistrano進行部署。在我嘗試部署新代碼後,最終出現此錯誤。這些東西在當地運行良好,問題僅在生產中發生。
錯誤詳細信息:
Web application could not be started.
uninitialized constant Users (NameError)
/home/ubuntu/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
/home/ubuntu/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
/home/ubuntu/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
/home/ubuntu/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
/home/ubuntu/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `each'
/home/ubuntu/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `call'
/home/ubuntu/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
/home/ubuntu/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
/home/ubuntu/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
Capistrano的部署成功完成沒有錯誤。
守則authentications_controller.rb是
class Users::AuthenticationsController < Devise::AuthenticationsController
def index
@authentications = current_user.authentications if current_user
end
def create
auth = request.env["rack.auth"]
current_user.authentications.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])
flash[:success] = "Authentication successful."
redirect_to authentications_url
end
def destroy
@authentication = current_user.authentications.find(params[:id])
@authentication.destroy
flash[:success] = "Successfully destroyed authentication."
redirect_to authentications_url
end
end
請正確格式化您的代碼和錯誤 – 2015-02-12 03:40:42
完成。感謝您的通知。 – Antriksh 2015-02-12 03:44:28
您是否也可以從authentications_controller.rb粘貼您的代碼 – 2015-02-12 04:17:43