2017-05-17 52 views
-1

Im stack with this devise routes error。这个问题只在我的生产 服务器,但在我本地没有问题。路由问题设计

我使用Phusion Passenger Apache。为我的生产设置。错误是。

uninitialized constant User::RegistrationsController 

我的routes.rb占优控制器

devise_for :users, :controllers => { registrations: 'user/registrations'} 

Path是

app/controllers/User/registrations_controller.rb 

应用程序/控制器/用户/ registrations_controller.rb

class User::RegistrationsController < Devise::RegistrationsController 
    before_filter :authenticate_person!, :redirect_unless_admin 


    def create 
     build_resource(sign_up_params) 
     resource.save 
     yield resource if block_given? 

    if resource.persisted? 
    if resource.active_for_authentication? 
    set_flash_message! :notice, :signed_up 
    #sign_up(resource_name, resource) 
    #respond_with resource, location: 
    after_sign_up_path_for(resource) 
    redirect_to new_user_registration_path 
    else 
    set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}" 
    expire_data_after_sign_in! 
    # respond_with resource, location: after_inactive_sign_up_path_for(resource) 
    end 
else 
    clean_up_passwords resource 
    set_minimum_password_length 
    respond_with resource 
end 
end 

private 

def redirect_unless_admin 
    unless current_person.is_a?(Admin)  
    redirect_to root_path 
    end 
end 


def sign_up_params 
    params.require(:user).permit(:username,:email, :password, :password_confirmation,:company, :branch, :branch_id) 
end 

def account_update_params 
params.require(:user).permit(:username, :branch, :company, :email, :password, :password_confirmation, :current_password) 
end 
end 

迫切需要帮助的感谢。

+1

你能请告诉你的注册控制器?除非另有说明,路径总是较低的,但我不认为这是造成问题的原因 – Mark

+0

@Mark我添加了registrations_controller.rb – coolshox

+1

路径必须是小写,'user'而不是'User' – Iceman

回答

-1

我认为问题在于你的路线本身,它应该是用户/注册而不是用户/注册。

如果仍然无法正常工作,/留下它在用户注册的路线,并保存您的控制器:

app/controllers/users/registrations_controller.rb 

和顶线更改为:

module Users 
    class RegistrationsController < Devise::RegistrationsController 

哪应该修复它

编辑:正如在初始评论中提到,路径是全部小写