"无法启动Web应用程序。未初始化的常量用户(NameError)"

时间:2015-02-12 03:37:21

标签: ruby-on-rails ruby-on-rails-4 capistrano passenger

在我通过Facebook和Google实施身份验证之前,我的应用程序中的所有内容都运行良好。

该应用程序托管在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

2 个答案:

答案 0 :(得分:0)

如果课程为Users::AuthenticationsController,则其路径应为app/controllers/users/authentications_controller.rb

答案 1 :(得分:0)

Devise没有身份验证控制器。尝试删除此文件并使用默认的设计控制器。