単純なフォームをまとめようとしていますが、フォーム フィールドを html に挿入するたびに no method エラーが発生します。
ここで何が問題なのですか?
エラー:
undefined method `name' for #<Upload id: nil, created_at: nil, updated_at: nil>
new.html.erb
<h1>Uploads#new</h1>
<p>Find me in app/views/uploads/new.html.erb</p>
<% form_for :upload, :url => uploads_path do |f| %>
<p>
Name: <%= f.text_field :name %>
</p>
<p><%= submit_tag "Create Upload" %></p>
<% end %>
アップロード.rb
class Upload < ActiveRecord::Base
has_many :tasks
end
uploads_controller.rb
class UploadsController < ApplicationController
def index
@uploads = Upload.find(:all)
end
def new
@upload = Upload.new
end
def create
@upload = Upload.new(params[:project])
if @upload.save
flash[:notice] = "Film successfully uploaded"
redirect_to uploads_path
else
render :action => 'new'
end
end
end