本文介绍了RoR 教程第 5.5 节 db:migrate 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Ruby 的新手.我在 RoR 入门第 5.5 节,在运行 db:migrate 后,出现以下错误.关于为什么的任何建议?我找不到任何答案或解决方案或问题.请帮忙.

i'm new to Ruby. I'm at RoR Getting Started Section 5.5 and after running db:migrate, got the below error. Any advise on why? I can't find any answers or solution or problem. Pls help.

$ bin/rake db:migrate

== 20150207172154 CreateArticles:迁移 ====================================-- create_table(:articles) -> 0.0017s== 20150207172154 CreateArticles:迁移(0.0019s)==========================

== 20150207172154 CreateArticles: migrating =================================== -- create_table(:articles) -> 0.0017s == 20150207172154 CreateArticles: migrated (0.0019s) ==========================

抽水中止!标准错误:发生了错误,这和以后迁移已取消:

rake aborted! StandardError: An error has occurred, this and all later migrations canceled:

错误数量的参数(1 代表 0)-e:1:in '参数错误:参数数量错误(1 代表 0)-e:1:in' 任务:TOP => db:migrate(使用 --trace 运行任务查看完整跟踪)

wrong number of arguments (1 for 0)-e:1:in <main>' ArgumentError: wrong number of arguments (1 for 0) -e:1:in' Tasks: TOP => db:migrate (See full trace by running task with --trace)

下面是我的迁移文件.

class CreateArticles < ActiveRecord::Migration    def change
    create_table :articles do |t|
      t.string :title
      t.text :text

      t.timestamps null: false
    end      
  end  
end

推荐答案

这是我遇到过一次的错误,是因为Arel gem的原因,要解决,去Gemfile,加上这一行

This is an error that I ran into once, and it's because of Arel gem, to solve it, go to Gemfile, and add this line

gem 'arel', '6.0.0.beta2'

然后从终端运行 bundle.如果它抱怨 Arel,则通过键入 bundle update arel 从终端安装它.然后再次迁移您的数据库.

then run bundle from the terminal. If it complains about Arel, then install it from the terminal by typing bundle update arel. Then migrate your database again.

这篇关于RoR 教程第 5.5 节 db:migrate 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 17:47