Ruby on rails 路由错误未初始化常量UsersController

Ruby on rails 路由错误未初始化常量UsersController,ruby-on-rails,routing,Ruby On Rails,Routing,我正在编写一个学习Rails开发的教程 如果这个问题是多余的,我道歉。这可能是因为我的初学者经验水平使我很难找到相关的现有答案 非常感谢您的帮助 本课程的目标是构建一个类似Reddit的站点。在本课中,我将利用S3存储和CarrierWave和MiniMagick gems实现图像上传。据我所知,我已经严格遵守了课程的说明,但也许我遗漏了什么 当我试图从“编辑”视图上载图像文件时,就会发生这种情况 以下是错误: app/controllers/users_controller.rb:5:in `

我正在编写一个学习Rails开发的教程

如果这个问题是多余的,我道歉。这可能是因为我的初学者经验水平使我很难找到相关的现有答案

非常感谢您的帮助

本课程的目标是构建一个类似Reddit的站点。在本课中,我将利用S3存储和CarrierWave和MiniMagick gems实现图像上传。据我所知,我已经严格遵守了课程的说明,但也许我遗漏了什么

当我试图从“编辑”视图上载图像文件时,就会发生这种情况

以下是错误:

app/controllers/users_controller.rb:5:in `update'


Rendered /Users/gregorybowler/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (8.5ms)
Rendered /Users/gregorybowler/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (3.5ms)
Rendered /Users/gregorybowler/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (2.4ms)
Rendered /Users/gregorybowler/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (64.7ms)
Cannot render console with content type multipart/form-dataAllowed content types: [#<Mime::Type:0x007fd34a40cb10 @synonyms=["application/xhtml+xml"], @symbol=:html, @string="text/html">, #<Mime::Type:0x007fd34a40ce30 @synonyms=[], @symbol=:text, @string="text/plain">, #<Mime::Type:0x007fd3493e8d88 @synonyms=[], @symbol=:url_encoded_form, @string="application/x-www-form-urlencoded">]


Started PATCH "/users/8" for ::1 at 2015-07-03 22:05:20 -0700

ActionController::RoutingError (uninitialized constant UsersController):
activesupport (4.2.1) lib/active_support/inflector/methods.rb:261:in `const_get'
activesupport (4.2.1) lib/active_support/inflector/methods.rb:261:in `block in constantize'
activesupport (4.2.1) lib/active_support/inflector/methods.rb:259:in `each'
activesupport (4.2.1) lib/active_support/inflector/methods.rb:259:in `inject'
activesupport (4.2.1) lib/active_support/inflector/methods.rb:259:in `constantize'

当我看到它时,我皱了整整10分钟的眉头。该错误表明它找不到类的
userscoontroller
常量


你说是在
user\u controller.rb
。然而,Rails自动加载只希望找到
userscoontroller
,注意你猜到的,
app/controllers/users\u controller.rb
。(很高兴记住,按照惯例,
{thing}Controller
是复数)

非常感谢您的回复。我有一种可能是罪魁祸首的感觉,因为我知道这个约定,我想知道如何重构代码或文件名来纠正这个问题。但是,当我将文件名更改为users_controller.rb时,我得到了一个我不理解的新错误:
在2588ms(ActiveRecord:11.2ms)内完成了500个内部服务器错误Excon::Errors::BadRequest(预期(200)实际(400个坏请求)excon.error.response
。如果这是一个幼稚的回答,很抱歉。我不确定如何修复。@user2860664看起来我们找到了这个问题的答案,而您遇到了一个单独的问题。听起来好像是S3上载和Carrierwave的问题。谢谢,您的回答确实正确。另一个问题是次要问题,我通过更改我的s3区域。
class UsersController < ApplicationController
  before_action :authenticate_user!

def update
  if current_user.update_attributes(user_params)
    flash[:notice] = "User information updated"
    redirect_to edit_user_registration_path
  else
    flash[:error] = "Invalid user information"
    redirect_to edit_user_registration_path
  end
end

 private

 def user_params
   params.require(:user).permit(:name, :avatar)
 end
end
Rails.application.routes.draw do
  devise_for :users
  resources :users, only: [:update]

resources :topics do
  resources :posts, except: [:index]
end

  get 'about' => 'welcome#about'

  root to: 'welcome#index'
end