2
我有一个微不足道的rake脚本来删除网页。它的路径是lib/tasks/scrape.rake。当运行rake db时,rails rake运行lib/tasks/scrape.rake:migrate
[email protected]:~/snowcrash$ ls lib/tasks/
scrape.rake
我也有一些DB数据库迁移脚本/迁移:
[email protected]:~/snowcrash$ ls db/migrate/
20110307213515_create_questions.rb
20110310010000_create_answers.rb
20110313191820_add_question_id_to_answers.rb
问题是,当我运行耙分贝:迁移。这似乎也跑我的lib /任务/ scrape.rake任务:
[email protected]:~/snowcrash$ rake db:migrate
(in /home/dan/snowcrash)
Fetched document: http://www.baidu.com/s?wd=love+me
\t Content Type: text/html\n
\t Charset: gbk\n
\t Content-Encoding: \n
\t Last Modified: \n\n
== AddQuestionIdToAnswers: migrating =========================================
-- add_column("questions", "answer_id", :integer)
-> 0.4923s
-- add_index("questions", "answer_id")
-> 0.4954s
== AddQuestionIdToAnswers: migrated (0.9881s) ================================
我做了一些google搜索,发现这个文档:http://jasonseifer.com/2010/04/06/rake-tutorial。他指出:
Rails将在lib/tasks中自动提取任务 。
如何让“rake db:migrate”不能运行我的其他rake任务?我有什么选择?
你完全正确。我没有把它包装在一个任务中! :d – sybind 2011-03-13 20:24:32