2015-02-12 39 views
0

在我通過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 
+0

請正確格式化您的代碼和錯誤 – 2015-02-12 03:40:42

+1

完成。感謝您的通知。 – Antriksh 2015-02-12 03:44:28

+0

您是否也可以從authentications_controller.rb粘貼您的代碼 – 2015-02-12 04:17:43

回答

0

如果該類Users::AuthenticationsController,那麼它的路徑應該是app/controllers/users/authentications_controller.rb

+0

我也試過那個。但在這種情況下,也會出現相同的錯誤,只是錯誤更改爲: 未初始化的常量用戶(NameError) /opt/app/sellzie.com/releases/20150212065828/app/controllers/Users/authentications_controller.rb:1:in' ' 兩者都用於本地身份驗證。但在生產中沒有任何作用。 – Antriksh 2015-02-12 07:03:47

0

設計不具有認證控制器。嘗試刪除此文件並使用默認的設備控制器。

相關問題