在我的路線文件我有:在Rails 3中,form_for是否應該自動知道模型的名稱助手是否被覆蓋?
resources :features, :as => 'featured'
然而,當我使用以下命令:
<% form_for @feature, :html => { :multipart => true } do |f| -%>
<%= render :partial => "form", :locals => { :f => f } -%>
<p><%= submit_tag "Feature these submissions" -%></p>
<% end -%>
我收到此錯誤:
「未定義的方法`features_path」爲#<# :0x00000106228ec0>「
這是我在」features_controller「中的」新「方法:
def new
@feature = Feature.new
@submissions = Submission.find(pending_featured_submissions)
end
在升級到Rails 3之前,Rails能夠知道我使用的是自定義的名稱助手。現在看起來好像form_for忽略了我的資源文件中的行並使用了features_path,而應該使用featured_path。
也許我做錯了什麼,或缺少什麼。
爲尋找謝謝=)
你是對的幫助者應該更新到featured_path。究竟是什麼時候拋出這個錯誤? – 2011-03-03 01:39:41
我在這裏粘貼了完整的輸出:http://pastebin.com/HP2yf5D7。在導航到「features_controller」中的「新」方法時拋出它。 – jklina 2011-03-03 01:58:40
您是否在編輯路線後重新啓動導軌服務器? – rubyprince 2011-03-03 02:28:41