Undefined method <model_name>_index_path for rails 3.2

孤者浪人 提交于 2020-01-06 07:00:20

问题


Okay, this continues to baffle me:

1) This is in my controller (personalias_controller.rb)

def new
  @personalia = Personalia.new
end

2) I've got a model called personalia.rb

3) I've got

resources :personalias

in routes.rb

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| %>

It's driving me nuts :-|


回答1:


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 > initializers > inflections.rb

ActiveSupport::Inflector.inflections do |inflect|
  inflect.irregular 'personalia', 'personalias'
end


来源:https://stackoverflow.com/questions/12478612/undefined-method-model-name-index-path-for-rails-3-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!