0
我想知道是否有可能將設計模型放入子文件夾&模塊。將設計模塊放入自定義模塊
例如:
/models/back_office/user.rb
module BackOffice
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :ldap_authenticatable, :timeoutable, :trackable
end
end
和相應的控制器:
/controllers/back_office/users/sessions_controller.rb
module BackOffice
module Users
class SessionsController < Devise::SessionsController
layout false
def create
# Check if user is already signed in. If true, destroy user session.
# This code prevents logging in if user pressed 'back' button and tried to log in again
# with improper password.
sign_out current_user if user_signed_in?
super
end
def after_sign_out_path_for(_resource_or_scope)
new_user_session_path
end
end
end
end
用這種方法我收到
somepath/gems/activesupport-4.2.4/lib/active_support/inflector/methods.rb:261:in 'const_get': uninitialized constant User (NameError)
找出了這短短的幾秒鐘前。謝謝 :) – Robs