Rails:生产中的操作错误,但不在开发中

时间:2012-04-21 16:50:25

标签: ruby-on-rails omniauth ruby-on-rails-3.2

任何人都可以解释为什么我一直在生产中出错而不是在开发中出错?相关部分:

get: /user/logout
ActionController::RoutingError (uninitialized constant User::SessionController):
  activesupport/lib/active_support/inflector/methods.rb:229:in `block in constantize'
  activesupport/lib/active_support/inflector/methods.rb:228:in `each'
  activesupport/lib/active_support/inflector/methods.rb:228:in `constantize'
  actionpack/lib/action_dispatch/routing/route_set.rb:69:in `controller_reference'
  actionpack/lib/action_dispatch/routing/route_set.rb:54:in `controller'
  actionpack/lib/action_dispatch/routing/route_set.rb:32:in `call'
  journey/lib/journey/router.rb:68:in `block in call'
  journey/lib/journey/router.rb:56:in `each'
  journey/lib/journey/router.rb:56:in `call'
  actionpack/lib/action_dispatch/routing /route_set.rb:600:in `call'
  omniauth/lib/omniauth/strategy.rb:177:in `call!'
  omniauth/lib/omniauth/strategy.rb:157:in `call'
  omniauth/lib/omniauth/builder.rb:48:in `call'
  airbrake/lib/airbrake/rack.rb:27:in `call'

路线:

Application1::Application.routes.draw do
  match('/auth/:provider/callback' => 'session#create', :format => false)
  root(:to => 'blog/archives#index', :format => false)

  namespace(:user) do
    match('/logout' => 'session#destroy', :format => false)
  end 

  namespace(:blog) do
    match('/archive/:slug' => 'archive#show', :format => false)
    constraints(:page => /page\d+/) do
      match('/archives/:page' => 'archives#index', :format => false)
    end 
  end 
end

我正在使用Rails 3.2.3和最新的Omniauth。

1 个答案:

答案 0 :(得分:0)

您已创建名称空间用户,因此您应在此路径中放置会话控制器,以定义销毁操作:

/app/controllers/user/session_controller.rb

然后你可以做类似的事情:

/app/controller/user/base_controller.rb中创建一个定义此文件的文件:

class User::BaseController < ApplicationController
 # Whatever you want here
end

将位于/app/controllers/user/session_controller.rb的会话控制器定义为:

class Users::SessionsController < User::BaseController
 def destroy
  # whatever you want destroy to do..
 end
end

阅读this以获取有关命名空间和路由的更多文档。

相关问题