Attempting to use form_for, I have been getting the error "First argument in form caot contain nil or be empty." The error is highlited in the first line: <%= form_for @item do |f| %> #------error highlited here <%= f.label :Task %> <%= f.text_field :name, placeholder: "What do you have to do?" %> <% end %> partial: <%= form_for @item do |f| %> <%= f.label :Task %> <%= f.text_field :name, placeholder: "What do you have to do?" %> <% end %> Controller: ```
class ItemsController < ApplicationController
def index
@items = Item.all
end
def new
@item = Item.new
end
def create
@item = Item.new
@item.name = params[:item][:name]
@item.user = current_user
if @item.save
flash[:notice] = "Item added; go accomplish it!"
else
flash.now[:alert] = "Uh oh, it didn't save. Try again."
render :new
end
end
def show
@item = Item.find(params[:id])
end
end
```
And, the show view(where I call the partial): <%= render partial: 'items/form', item: Item.new, locals: {items: @item} %>
So far, my research has indicated the problem could be in any of these files. I have already seen that I could simply write, <%= form_for Item.new do |f| %>, but I want to avoid that because all have recommended against it. How is this error fixed? How do I make sure the first argument isn't empty/nil?(I did create an item in the Rails console)
