First argument in form cannot contain nil or be empty – Rails 4

The error message is telling you that you can’t have the following:

<%= form_for nil do |f| %>
<%= form_for [] do |f| %>

My guess here is that your @contact is set to nil and that it doesn’t come from your Contact#new action.

FYI it would simply work if you do this:

<%= form_for do |f| %>

Though it is not recommended.

You need to check that the view containing your form is actually rendered by the new action of your ContactsController.

Leave a Comment