Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
804 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...