質問

I installed paperclip 2.7 using gem install. I did rails generate paperclip user photo. and then tried migrate the db. But it gave me an error. SQLite3::SQLException: duplicate column name: photo_file_name: ALTER TABLE "users" ADD "photo_file_name" varchar(255)

I read somewhere that I should do delete the development.rb and then do db:create and them migrate again. But that didn't work either. When I did db:create it said already exists. So...I ended up reverting back to my old commit hoping to start again. But when I do db:reset. it tell me i have two migrations left. These two migrations are from rails generate paperclip user photo. What do I do now? How am I to get this to work?

役に立ちましたか?

解決

if you don't have any data that is important and needs to be saved you can simply drop the db and migrate it all the way back up:

rake db:drop

rake db:create

rake db:migrate

他のヒント

Run a migration removing photo_file_name, thus:

def change
  change_table :users do |t|
    t.remove :photo_file_name
  end
end

And start again.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top