Rails 3.2 的未定义方法 <model_name>_index_path [英] Undefined method <model_name>_index_path for rails 3.2
问题描述
好吧,这让我继续困惑:
Okay, this continues to baffle me:
1) 这是在我的控制器中 (personalias_controller.rb)
1) This is in my controller (personalias_controller.rb)
def new
@personalia = Personalia.new
end
2) 我有一个名为personalia.rb的模型
2) I've got a model called personalia.rb
3) 我有
resources :personalias
在routes.rb
当我尝试呈现个性化表单时,我仍然得到未定义的方法`personalia_index_path'(来自views/personalias/new.html.erb:
Still I get undefined method `personalia_index_path' when I try to render the personalia form as such (from within views/personalias/new.html.erb:
<%= form_for @personalia do |f| %>
这让我发疯:-|
推荐答案
这可能是因为personalias 不是personalia 的复数,你可以在你的控制台中使用"personalia".pluralize
检查这个可以添加一个拐点并重新启动您的应用程序,方法如下:
It is probably becouse personalias is not the plural of personalia, you can check this in your console using "personalia".pluralize
you could add an inflection and restart your app, here is how:
config > 初始化程序 > inflections.rb
config > initializers > inflections.rb
ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular 'personalia', 'personalias'
end
这篇关于Rails 3.2 的未定义方法 <model_name>_index_path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!