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

SOLVED - Attaching Files - Part 2

After running the rake db:migrate I get the following error:

QLite3::SQLException: table documents has no column named user_id: CREATE INDEX "index_documents_on_user_id" ON "documents" ("user_id")/usr/local/rvm/gems/ruby-1.9.3-p448/gems/sqlite3-1.3.8/lib/sqlite3

migrationdate_create_documents.rb:

class CreateDocuments < ActiveRecord::Migration
  def change
    create_table :documents do |t|

      t.timestamps
    end

    add_index :documents, :user_id
    add_attachment :documents, :attachment
    add_column :statuses, :document_id, :integer
  end
end

Homebrew, paperclip, thin and log buddy are all installed in the Gemfile. I've tried rake db:reset and rake db:setup but they all saying "pending migration" but the migration won't run.

Any thoughts or ideas? I haven't had this problem with my other database files.

1 Answer

I forgot to add t.integer :user_id inside of create_table... DOH!