ActionController :: RoutingError(未初始化的常量ImporterController):

时间:2014-01-27 07:36:23

标签: ruby-on-rails ruby ruby-on-rails-3.2 redmine rails-routing

我的route.rb文件看起来像

RedmineApp::Application.routes.draw do
  match 'importer/:action', :controller => 'importer'
end

我得到的错误是

ActionController::RoutingError (uninitialized constant ImporterController):
activesupport (3.2.11) lib/active_support/inflector/methods.rb:219:in `constantize'
activesupport (3.2.11) lib/active_support/inflector/methods.rb:218:in `each'
activesupport (3.2.11) lib/active_support/inflector/methods.rb:218:in `constantize'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:69:in `  controller_reference'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:54:in `controller'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:32:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:601:in `call'
rack-openid (1.4.2) lib/rack/openid.rb:98:in `call'
pdfkit (0.5.4) lib/pdfkit/middleware.rb:16:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'

rack (1.4.5) lib/rack/handler/webrick.rb:13:in `run'
rack (1.4.5) lib/rack/server.rb:268:in `start'
railties (3.2.11) lib/rails/commands/server.rb:70:in `start'
railties (3.2.11) lib/rails/commands.rb:55
railties (3.2.11) lib/rails/commands.rb:50:in `tap'
railties (3.2.11) lib/rails/commands.rb:50
script/rails:6:in `require'
script/rails:6

我的rails -v是3.2.11 ruby​​ -v是1.8.7 我正在Red mine中导入to_csv插件,我收到了此错误

3 个答案:

答案 0 :(得分:1)

使用此

match '/importers/action_name' => 'importers#action_name'

还有一个控制器名称是复数

对进口商来说是正确的进口商。

答案 1 :(得分:0)

尝试以下语法

match 'importers', to: 'importers#action', via: [:get, :post]

答案 2 :(得分:0)

确保您的控制器是ApplicationController

的孩子

ImporterController < ApplicationController