Search code examples
ruby-on-rails-3production-environment

Rails Routing Error only in production


Hello i have this in routes.rb

  namespace :admin do
    root :to => "admin#index"
    resources :employees
    resources :customers
    resources :users
  end

frontend normally works, i can login to administration but there i have link like

<li><%= link_to "users", admin_users_path %></li>

etc..

if i click on that link i get this error

uninitialized constant Admin::UsersController

or if i click on admin_employees_path i get

uninitialized constant Admin::EmployeesController

and that behavior is at every link in administration

at server with rails s everything is fine :p

user controller is defined like that

class UsersController < Admin::AdminController

files location controllers/admin/admin_controller.rb controllers/users_controller.rb

My environments files

development.rb

Web::Application.configure do
  config.cache_classes = false
  config.whiny_nils = true
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false
  config.action_mailer.raise_delivery_errors = false
  config.active_support.deprecation = :log
  config.action_dispatch.best_standards_support = :builtin
  config.active_record.mass_assignment_sanitizer = :strict
  config.active_record.auto_explain_threshold_in_seconds = 0.5
  config.assets.compress = false
  config.assets.debug = true
end

production.rb

Web::Application.configure do
  config.cache_classes = true # different
  config.assets.compress = true # different

  config.consider_all_requests_local       = true # temporary true
  config.action_controller.perform_caching = false

  # not in development
  config.serve_static_assets = false
  config.assets.compile = true
  config.assets.digest = true
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
end

Solution

  • You are defining your users resource under the admin namespace but not defining it in the controller.

    Move your users_controller to /controllers/admin/users_controller and append the namespace to that class declaration

    class Admin::UsersController < Admin::AdminController

    Or move your resources :user outside the admin namespace.