Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 我的联系人表单出错,联系人中的NoMethodError#新建_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails 我的联系人表单出错,联系人中的NoMethodError#新建

Ruby on rails 我的联系人表单出错,联系人中的NoMethodError#新建,ruby-on-rails,ruby,Ruby On Rails,Ruby,我在尝试创建新电子邮件时遇到此错误。发生了什么事 NoMethodError in Contacts#new blog/app/views/contacts/new.html.erb where line #4 raised: undefined method `contacts_path' for #<#<Class:0x007fab694b2320>:0x007fab6bdde2a8> Did you mean? controller_path 联系人中的命名

我在尝试创建新电子邮件时遇到此错误。发生了什么事

NoMethodError in Contacts#new

blog/app/views/contacts/new.html.erb where line #4 raised:

undefined method `contacts_path' for #<#<Class:0x007fab694b2320>:0x007fab6bdde2a8>
Did you mean?  controller_path
联系人中的命名错误#新增 blog/app/views/contacts/new.html.erb,其中第4行出现: 未定义的方法“联系人路径”# 你是说?控制器路径 这是我的密码:

<div class="skinny_wrapper wrapper_padding">
<%= form_for @contact do |f| %>
    <%= f.label :name %><br>
    <%= f.text_field :name, required: true %>



好的,快速查看您的路线。rb

resources :contacts, only: [:new, :created]
如果格式不正确,则应:

resources :contacts, only: [:new, :create]

可能就是这样。要查看发生了什么,您可以运行rake routes,然后您将看到您的路由列表。然后可以修复路由文件,使其具有适当的路由路径

欢迎使用堆栈溢出!我之所以编辑这个标题,是因为指定了什么技术是不必要的,这就是标签的用途。我还修改了单词的语法和大小写。我做的另一件事是格式化错误,以便更容易阅读。最后,我格式化了指向存储库的链接。希望你得到你的答案!谢谢,对不起,我的语法不是以英语为母语的。