Philip7899
Philip7899

Reputation: 4677

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). For some reason I get the error:

undefined method `referrals_path' for #<#<Class:0x007fba5a11b4a0>:0x007fba5a119a10>

What am I doing wrong?

Upvotes: 1

Views: 131

Answers (1)

Mandeep
Mandeep

Reputation: 9173

You are getting this error because there is no referrals_path. You have double l in referalls

resources :referalls, only: [:create] 

but it should be

resources :referrals, only: [:create]

Upvotes: 3

Related Questions