我想知道是否可以将设计模型放入子文件夹&模块。
例如:
/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)
答案 0 :(得分:1)
您可以通过在声明身份验证路由时传递public double recursionMethod(int a, int b){
int c = a+b;
if(Math.abs(ratio(b,a)-ratio(c,b))< (double) 1/42)
return ratio(c,b);
else
return recursionMethod(b,c);
}
选项,显式设置设计用于身份验证的资源的类名。
class_name