Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/55.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 OmniAuth create中的DangerousAttributeError由ActiveRecord定义_Ruby On Rails_Database_Ruby On Rails 3_Omniauth_Railscasts - Fatal编程技术网

Ruby on rails OmniAuth create中的DangerousAttributeError由ActiveRecord定义

Ruby on rails OmniAuth create中的DangerousAttributeError由ActiveRecord定义,ruby-on-rails,database,ruby-on-rails-3,omniauth,railscasts,Ruby On Rails,Database,Ruby On Rails 3,Omniauth,Railscasts,请查看此页,因为我有相同的问题: 然而,对于rails来说,这是一个相当新的概念,我不太确定如何从数据库中删除他们提到的字段。换言之,在那篇文章的任何地方都没有一步一步的简明描述 下面的帖子事实上是一个正确的解决方案,但不清楚他在写“rails g迁移删除\愚蠢\认证\字段\哪些不应该\不应该\不应该\不应该\在那里”时所指的是什么 以下是我所指的帖子: 因此,为了完成这个问题,您需要创建一个迁移 使用此命令: rails g migration drop_silly_controller_at

请查看此页,因为我有相同的问题:

然而,对于rails来说,这是一个相当新的概念,我不太确定如何从数据库中删除他们提到的字段。换言之,在那篇文章的任何地方都没有一步一步的简明描述

下面的帖子事实上是一个正确的解决方案,但不清楚他在写“rails g迁移删除\愚蠢\认证\字段\哪些不应该\不应该\不应该\不应该\在那里”时所指的是什么

以下是我所指的帖子:

因此,为了完成这个问题,您需要创建一个迁移 使用此命令:

rails g migration drop_silly_controller_attributes
rails-g迁移 删除\u愚蠢的\u身份验证\u字段\u不应该\u在那里\u

看起来是这样的:

class DropSillyControllerAttributes < ActiveRecord::Migration
  def change
    remove_column :authentications, :index
    remove_column :authentications, :create
    remove_column :authentications, :destroy
  end
end
类DropSillyControllerAttributes 并使用通常的方法运行它:

rake数据库:迁移

或者,您应该能够运行:

rake-db:回滚

要回滚刚刚对数据库所做的更改,请执行以下操作:

railsdscaffold身份验证

要删除所有文件,请运行:

rails g scaffold身份验证用户\u id:integer提供程序:字符串 uid:字符串

然后手动完成其他工作

顺便说一下,我自己也做了同样的事


它告诉您创建迁移以删除有问题的字段,然后运行迁移

更清楚地说:

运行以下命令:

rails g migration drop_silly_controller_attributes
该命令将在/db/migratie/中创建一个带有时间戳和名称的文件,类似于:

2013121212312312_drop_silly_controller_attributes.rb
打开该文件并将其修改为如下所示:

class DropSillyControllerAttributes < ActiveRecord::Migration
  def change
    remove_column :authentications, :index
    remove_column :authentications, :create
    remove_column :authentications, :destroy
  end
end
这是令人困惑的,因为如果生成迁移时使用了“remove\u duly\u authentication\u fields\u which\u not\u there”,那么类应该是removesillyaauthenticationfields,它不应该在这里,但随后会显示“DropSillyControllerAttributes”,因此,您应该使用drop\u-duly\u-controller\u属性生成迁移,以使其一致