Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 简单Rails 4迁移向Postgres投旗_Ruby On Rails_Ruby On Rails 4 - Fatal编程技术网

Ruby on rails 简单Rails 4迁移向Postgres投旗

Ruby on rails 简单Rails 4迁移向Postgres投旗,ruby-on-rails,ruby-on-rails-4,Ruby On Rails,Ruby On Rails 4,我在这里为我的第一个Rails 4项目做了一个简单的迁移。这是我的项目中的第一次迁移,在第一个模型上。我还试着做: rake db:forward STEP=1 但这没有起到任何作用,甚至连一个错误都没有。以下是迁移: class CreateOrganizations < ActiveRecord::Migration def change create_table :organizations do |t| t.string :org_type t

我在这里为我的第一个Rails 4项目做了一个简单的迁移。这是我的项目中的第一次迁移,在第一个模型上。我还试着做:

rake db:forward STEP=1
但这没有起到任何作用,甚至连一个错误都没有。以下是迁移:

class CreateOrganizations < ActiveRecord::Migration
  def change
    create_table :organizations do |t|
      t.string :org_type
      t.string :status
      t.string :name
      t.string :dba_name
      t.string :url
      t.text :description

      t.timestamps
    end
  end
end
该错误出现在ActiveRecord::SchemaMigration.version方法中,该方法仅调用
super.to\u i

它必须与
schema\u迁移
表有关。现在它是空白的。这几乎就像我错过了初始化步骤一样


我是不是领养得太早了,还是因为4而错过了什么?还请注意,所有数据库都已创建且确实存在。

我发现了错误。Postgresql允许版本化记录。至少,这是我的想法。无论如何,创建
schema_migrations
表时,它的一列
version
维度为1

我想我会在那里放一个零来愚弄Rails。好吧,博士后不让我增加价值!它以一种类似于Rails的方式抱怨,说数组必须以特定的方式格式化。那是我注意到尺寸的时候

我将
schema\u migrations.version
上的
dimension
字段从1更改为0。然后我重新进行了迁移,结果一切顺利


更新


这显然是Rails 4.0.2中的一个bug。幸运的是,Rails
4.0.3
昨天发布。查看此答案,了解如何克服此问题的步骤

undefined method `to_i' for []:Array/Users/me/.rvm/gems/ruby-2.0.0-p353@myapp/gems/activerecord-4.0.2/lib/active_record/schema_migration.rb:36:in `version'