【发布时间】:2014-03-23 13:28:42
【问题描述】:
当我遇到问题时,我正在阅读 Hartl 的 Ruby on Rail 教程第 4 章。在添加 full_title_helper.rb 文件之前,我的项目在 Rails 服务器中加载得很好。
我明白了:
RuntimeError(自动加载常量 FullTitleHelper 时检测到循环依赖):
app/controllers/application_controller.rb:1:in 'top (required)'
app/controllers/static_pages_controller.rb:1:in 'top (required)'
我尝试按照this suggestion 将 config.middleware.delete Rack::Lock 添加到我的 development.rb 文件中,但这没有帮助。
我尝试从 rails 4.0.2 切换到 4.0.0;那没用。
我的 full_title_helper.rb 直接来自Hartl's page
module ApplicationHelper
# Returns the full title with minor modifications depending on the page
def full_title(page_title)
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
end
我该怎么做才能解决这个问题?
【问题讨论】:
-
忽略这个问题。事实证明,这个助手应该是“application_helper.rb”而不是“full_title_helper.rb”更改文件的名称解决了问题。
标签: ruby-on-rails-4 railstutorial.org circular-dependency