我有一个表,我在需要小数位的字段上使用整数,所以我试图创建一个迁移,将字段类型从整数更改为float/real.我的数据库是sqllite3,我正在使用rails3.
我跑了
rails generate migration ChangeMeasureColumnOnIngredients
创建初始迁移文件,然后将类更新为
class ChangeMeasureColumnOnIngredients < ActiveRecord::Migration
def self.up
change_column :ingredients, :measure, :real
end
我运行了rake db:migrate并且返回正常.
当我通过我的rails应用程序插入一个值时,它没有返回小数位.我开始认为许多rails不知道'real'是什么作为数据类型,因此我将迁移更改为
change_column :ingredients, :measure, :float
然后我跑了
rake db:migrate change_measure_column_on_ingredients现在我收到以下错误
c:\Ruby192\rails3rc>rake db:migrate change_measure_column_on_ingredients (in c:/Ruby192/rails3rc) rake aborted! Don't know how to build task 'change_measure_column_on_ingredients' C:/Ruby192/lib/ruby/1.9.1/rake.rb:1720:in[]' C:/Ruby192/lib/ruby/1.9.1/rake.rb:2040:ininvoke_task' C:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:inblock (2 levels) in top_level' C:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:ineach' C:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:inblock in top_level' C:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:instandard_exception_handling' C:/Ruby192/lib/ruby/1.9.1/rake.rb:2013:intop_level' C:/Ruby192/lib/ruby/1.9.1/rake.rb:1992:inrun' C:/Ruby192/bin/rake:31:in `'
我尝试将:float更改为:real,但我仍然遇到了这个错误.
谁能告诉我我做错了什么?我是铁杆新手,还在学习.
我不确定如何使用Capistrano部署应用程序,但我想我至少尝试在部署服务器上加载我需要的所有文件,所以我在Github上做了一个git pull并使用bundle install安装了所有依赖项.我使用Rails 3.0.9在Ruby 1.9.2p180中运行RVM 1.6.32,当我运行rake db:migrate时,我得到了
rake aborted!
Don't know how to build task 'db:migrate'
我没有其他SO用户提到的双分号问题,所以我真的很困惑.我安装了0.9.2和0.8.7,以及捆绑器1.0.17.我的rvm实例显示
rake (0.8.7 ruby)
出了什么问题?
- 编辑 -
rake --tasks的输出
rake sunspot:reindex[batch_size,models] # Reindex all solr models that are...
rake sunspot:solr:run # Run the Solr instance in the for...
rake sunspot:solr:start # Start the Solr instance
rake sunspot:solr:stop # Stop the Solr instance
Run Code Online (Sandbox Code Playgroud)
宝石列表的输出是
gem list
*** LOCAL GEMS ***
aaronh-chronic (0.3.9)
abstract (1.0.0)
actionmailer (3.0.9)
actionpack (3.0.9)
activemodel (3.0.9)
activerecord (3.0.9)
activeresource (3.0.9) …Run Code Online (Sandbox Code Playgroud)