0
這是一個奇怪的問題。無法訪問幫助器方法?
在我的應用助手,有一個名爲測試方法,並命名爲article_url的另一種方法。我有文章資源,並生成它的url_helpers。在測試方法中,我打電話article_url,但它訪問url_helper方法,而不是我在助手中定義的方法。
我的項目在Rails 3.0中運行良好,但是當我升級到3.2時,它引發了這個問題。 3.2以下,開發模式運行良好但生產提出問題。
請原諒我的英語不好:-)
對不起,這樣的代碼:
# application_helper.rb
module ApplicationHelper
...
def article_url(article, html_suffix = true)
if article.redirect_to.present?
article.redirect_to
else
url = "#{Settings.host}/articles/#{article.created_at.strftime("%Y-%m-%d")}/#{article.id}"
url += ".html" if html_suffix
url
end
end
...
def render_article_list(article)
link_to(xxx, article_url(article), {:target => "_blank"})
end
end
向我們展示'code'和'error message' –
這是一個瘋狂的猜測。請嘗試將代碼「include ApplicationHelper」添加到ApplicationController中,然後對其進行測試。 –
謝謝,代碼補充。 – winterwhisper