“Web应用程序无法启动。未初始化的常量用户(NameError)”
在我通过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
如果该类Users::AuthenticationsController
,那么它的路径应该是app/controllers/users/authentications_controller.rb
我也试过那个。但在这种情况下,也会出现相同的错误,只是错误更改为: 未初始化的常量用户(NameError) /opt/app/sellzie.com/releases/20150212065828/app/controllers/Users/authentications_controller.rb:1:in'
设计不具有认证控制器。尝试删除此文件并使用默认的设备控制器。
请正确格式化您的代码和错误 – 2015-02-12 03:40:42
完成。感谢您的通知。 – Antriksh 2015-02-12 03:44:28
您是否也可以从authentications_controller.rb粘贴您的代码 – 2015-02-12 04:17:43