Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
783 views
in Technique[技术] by (71.8m points)

ruby on rails - On Migration: undefined method `to_sym' for nil:NilClass

I'm running Rails 3.0.3 and I accidentally made a typo in my migration: I created a migration that creates a new column with a type of boolen (it should have been boolean). I ran the migration and Rails didn't warn me that this was an invalid type of column, which I could have sworn it did in previous versions?

Now whenever I try to add, remove, or modify anything in a migration I get the following error:

undefined method `to_sym' for nil:NilClass

I can't even rollback or drop. I have an earlier version of the database and file tree saved, but this problem is driving me crazy because it isn't the first time I've seen this happen.

How can I effectively remove the column without having Rails complain (and preferably without digging into the database by hand)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you are using the SQLite database, you probably getting this error because SQLLite doesn't provide the drop column feature. http://www.sqlite.org/faq.html#q11

SQLLite suggests that you create a temporary table with only the columns that you need from your original table, transfer data, and then swap the tables.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...