我在迁移期间遇到了基本的 Rails 问题。这是两个脚本
class CreateGoogleMaps < ActiveRecord::Migration
def self.up
create_table :google_maps do |t|
t.string :name, :null => false
t.string :description
t.column "center", :point, :null => false, :srid => 4326, :with_z => false # 4326: WSG84
t.integer :zoom
t.datetime :created_at
t.datetime :updated_at
t.integer :created_by_id
t.integer :updated_by_id
end
end
def self.down
drop_table :google_maps
end
end
文件 #2 +++ 003_add_map_style.rb ++++++
class AddMapStyle < ActiveRecord::Migration
def self.up
add_column :google_maps, :style, :integer
GoogleMaps.update_all( "style = 1")
end
def self.down
remove_column :google_maps, :style
end
end
***********************************************
这是我在迁移期间看到的内容 == CreateGoogleMaps:迁移 ====================================== ========== -- create_table(:google_maps) -> 0.0638s == CreateGoogleMaps: 已迁移 (0.0640s) ==================== ===================
== CreateMarkers:迁移 ============================================= ===== -- create_table(:markers) -> 0.0537s == CreateMarkers: 迁移 (0.0539s) ======================== =================
== AddMapStyle:迁移 ============================================== ======= -- add_column(:google_maps, :style, :integer) -> 0.0406s rake 中止!发生错误,所有后续迁移均已取消:
未初始化的常量 AddMapStyle::GoogleMaps
我正在使用 Rails 2.3.11。非常感谢任何调试提示!