0

I'm trying to put a simple form together, but I keep getting a no method error whenever I insert a form field into the html.

What's wrong here?

The Error:

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 %>

upload.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
1
  • has_many :tasks. Is there a tasks.rb file/class? Commented May 18, 2012 at 3:12

1 Answer 1

1

From looking at the error, your upload model does not appear to have a name attribute. If you've added this, the maybe you have forgotten to migrate you database?

Sign up to request clarification or add additional context in comments.

2 Comments

that's definitely not it. any other ideas?
@Adam appears to be right to me. Unless you are using a strange select query somewhere and renaming the name attribute but it doesn't look like it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.