我的配置路由中包含以下内容:
...
scope module: :public do
...
scope module: :doctor do
get 'vets/new', to: 'vets#new'
...
end
end
因此,嵌套是:公共->医生->兽医。
偶然,我将vets控制器放入 public 文件夹(app/controllers/public/vets_controller.rb
)中,并将其包装到Public模块中。并提出适当的观点:app/views/public/vets/new.html.slim
。
这些东西在我的本地计算机上正常工作,但是在部署过程之后,我收到404错误。
如何在开发模式下启用此检查?我需要在开发阶段就知道这类问题。
您为什么认为它甚至可以在我的本地计算机上运行?
答案 0 :(得分:1)
所有包含scope module: "etc"
的文档仅使用1级嵌套。
使用scope
嵌套的2个级别并不是预期的方式。 Rails在开发中没有注意到这些错误。
要获取所需的错误,请更改development.rb
文件中的某些配置选项。请注意它们与您的production.rb
文件有何不同。
# config/environments/development.rb
Rails.application.configure do
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# more code
end
收件人
# config/environments/production.rb
Rails.application.configure do
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot.
# This eager loads most of Rails and your application in memory,
# allowing both threaded web servers and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# more code
end