Dustin James
Dustin James

Reputation: 571

invoke active_record error

I'm trying to generate a Post model in rails using the following code:

rails g model Post url:string, title: string

When I execute that line I get the following output:

invoke  active_record
Another migration is already named create_posts: /Users/myname/Desktop/folder/my_project/db/migrate/20121212021831_create_posts.rb

It seems to be expressing a conflict as though the file already exists in my Model folder - which it does not.

Is this a naming problem? Any thoughts?

Upvotes: 1

Views: 1638

Answers (2)

siddick
siddick

Reputation: 1478

This problem can happen when you execute rails g model post for multiple times. You can resolve this issue by executing the rails destroy model post to remove last generated content.

Upvotes: 1

Fiona T
Fiona T

Reputation: 1929

The conflicting migration would be in your db/migrate folder, not app/models.

Your two options are naming your new migration something else or removing the old migration. If you choose to remove the old migration, make sure to roll it back first before deleting it, so that your database schema is correct.

Upvotes: 2

Related Questions