【问题标题】:railstutorial.org chap 4 full_title_helper.rb causes RuntimeError (Circular dependency detected...)railstutorial.org 第 4 章 full_title_helper.rb 导致 RuntimeError(检测到循环依赖...)
【发布时间】: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


【解决方案1】:

我的错误,我错误地命名了帮助文件。感谢所有看过这个问题的人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-19
    • 1970-01-01
    • 1970-01-01
    • 2022-10-07
    • 1970-01-01
    相关资源
    最近更新 更多