[英]Rails form is giving undefined method error
This seems like such an easy question, but I can't figure out what I'm doing wrong. 这似乎是一个简单的问题,但我无法弄清楚我做错了什么。 I have the following form code: 我有以下表单代码:
In the controller: 在控制器中:
class ProjectApplicationsController < ApplicationController
def new_project
@project.new
@referral = Referral.new
end
end
In the view: 在视图中:
<%= form_for @referral do |f| %>
<%= f.text_field :referrer_email %>
<% end %>
Routes File: 路线文件:
resources :referalls, only: [:create]
I have done this countless times before, the only difference being that the view the form is rendered from is different from the controller it is going to(the form should go to referrals#create). 我以前做过无数次这样做,唯一的区别是表单的呈现方式不同于它要进行的控制器(表单应该转到引用#create)。 For some reason I get the error: 出于某种原因,我得到错误:
undefined method `referrals_path' for #<#<Class:0x007fba5a11b4a0>:0x007fba5a119a10>
What am I doing wrong? 我究竟做错了什么?
You are getting this error because there is no referrals_path. 您收到此错误,因为没有referrals_path。 You have double l in referalls 在referalls中你有双倍的l
resources :referalls, only: [:create]
but it should be 但它应该是
resources :referrals, only: [:create]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.