Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Code challenge: Paperclip Migrations

I've read through the documentation, which is pretty straightforward, and entered in what I thought was the right code (or it appears to make sense). But it still doesn't pass.

class CreateDocuments < ActiveRecord::Migration
  def change
    create_table(:documents) do |t|
      t.integer :user_id
   end

 add_attachment :documents, :asset 

  end
end

is "add_attachment :documents, :asset" not the right line?

5 Answers

The line you're looking for is:

add_attachment :documents, :attachment

I'm getting an error when I try to upload a file:

"Document model missing required attr_accessor for 'attachment_file_name'"

so I downloaded the project files to check to see what's wrong, and so many of the files look way different than after the second course. Am I supposed to just copy these over? I suppose I know what they do, but I don't understand why so much was done to edit the code between the second fails course and this one.

what is the right line? I still haven't been able to get through with all my intuitions failing me.

yeah it's confusing.

Oh, it's covered in the next video. Including installing paperclip. I think the quiz should probably be after the following video, which is "attaching files", rather than directly after "installing paperclip" which doesn't install paperclip at all (though to be fair it's in the notes).

The right line for the quiz? Oh, he covers it in the next video. The quiz is, I think, in the wrong place.