В нашем приложении мы используем модули для организации некоторых контроллеров.Вот как выглядит структура каталогов:
app/
controllers/
admin/
products/
reviews_controller.rb
orders/
line_items_controller.rb
products_controller.rb
orders_controller.rb
Это отлично работает в процессе разработки, но не работает на нашем сервере AWS со следующей ошибкой:
{"method":"GET","path":"/api/","format":"html","controller":"ApplicationController","action":"main","status":200,"duration":5.03,"view":0.15,"db":1.46,"@timestamp":"2019-02-28T16:21:08Z","process_id":36,"ip":"10.41.143.0","owner_id":null,"owner_type":null,"params":{}}
ActionController::RoutingError (uninitialized constant Admin::Products::ProductsController):
activesupport (4.2.10) lib/active_support/inflector/methods.rb:263:in `const_get'
activesupport (4.2.10) lib/active_support/inflector/methods.rb:263:in `block in constantize'
activesupport (4.2.10) lib/active_support/inflector/methods.rb:259:in `each'
activesupport (4.2.10) lib/active_support/inflector/methods.rb:259:in `inject'
activesupport (4.2.10) lib/active_support/inflector/methods.rb:259:in `constantize'
actionpack (4.2.10) lib/action_dispatch/routing/route_set.rb:70:in `controller_reference'
actionpack (4.2.10) lib/action_dispatch/routing/route_set.rb:60:in `controller'
actionpack (4.2.10) lib/action_dispatch/routing/route_set.rb:39:in `serve'
actionpack (4.2.10) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.10) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.10) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.10) lib/action_dispatch/routing/route_set.rb:817:in `call'
rack (1.6.10) lib/rack/etag.rb:24:in `call'
rack (1.6.10) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.10) lib/rack/head.rb:13:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.10) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.10) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.10) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.10) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.10) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.10) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.10) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.10) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
rack-cors (1.0.2) lib/rack/cors.rb:97:in `call'
lograge (0.10.0) lib/lograge/rails_ext/rack/logger.rb:15:in `call_app'
railties (4.2.10) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.10) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.10) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.10) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.10) lib/rails/rack/logger.rb:20:in `call'
request_store (1.4.1) lib/request_store/middleware.rb:19:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.10) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.10) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.10) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/static.rb:120:in `call'
rack (1.6.10) lib/rack/sendfile.rb:113:in `call'
ddtrace (0.8.0) lib/ddtrace/contrib/rack/middlewares.rb:89:in `call'
sentry-raven (2.7.4) lib/raven/integrations/rack.rb:51:in `call'
railties (4.2.10) lib/rails/engine.rb:518:in `call'
railties (4.2.10) lib/rails/application.rb:165:in `call'
rack (1.6.10) lib/rack/urlmap.rb:66:in `block in call'
rack (1.6.10) lib/rack/urlmap.rb:50:in `each'
rack (1.6.10) lib/rack/urlmap.rb:50:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'
namespace :admin, shallow: true do
resources :products, module: 'products' do
resources :reviews
end
resources :orders, module: 'orders' do
resources :line_items
end
end
Я неуверен, почему он ищет Admin :: Products :: ProductsController, потому что контроллер продуктов находится под /app/controllers/admin/
, а не app/controllers/admin/products/
.
. Буду очень признателен за помощь.Мне трудно понять, почему это происходит только в производстве.
rake routes | grep 'products'
Это столько, сколько я могу поделиться на данный момент:
admin_products GET /admin/products(.:format) admin/products/products#index
POST /admin/products(.:format) admin/products/products#create
new_admin_products GET /admin/products/new(.:format) admin/products/products#new
edit_admin_products GET /admin/products/:id/edit(.:format) admin/products/products#edit
admin_product GET /admin/products/:id(.:format) admin/products/products#show
PATCH /admin/products/:id(.:format) admin/products/products#update
PUT /admin/products/:id(.:format) admin/products/products#update
DELETE /admin/products/:id(.:format) admin/products/products#destroy