2013-02-28 111 views
1

定义请参阅此页,因为我有同样的问题:DangerousAttributeError in OmniAuth Railscast Tutorial: create is defined by ActiveRecordDangerousAttributeError创建由ActiveRecord的

但是是相当新的轨道,我不是很确定为如何删除他们讲的领域来自数据库。换句话说,在这篇文章的任何地方都没有描述一步一步简洁的方式。

的后下其实是一个妥善的解决办法,但目前还不清楚为他指的是,当他写下了:“轨摹迁移remove_silly_authentication_fields_which_should_not_be_there”不知道什么是“silly_authentication_fields_which_should_not_be_there”正是。

这里我指的帖子:

所以刚完成的问题关闭,您将需要在使用该命令创建迁移 :

轨摹迁移 remove_silly_authentication_fields_which_should_not_be_there

看起来像这样:

class DropSillyControllerAttri butes <的ActiveRecord ::移民高清 变化 remove_column:认证,:指数 remove_column:认证,:创建 remove_column:认证,:摧毁年底结束

而且使用通常的运行它:

耙分贝:迁移

或者你也应该能够运行:

耙分贝:回滚

回滚只是对数据库所做的和变化:

轨d支架认证

要删除所有文件,然后运行:

轨摹支架认证USER_ID:整数提供商:字符串 UID:字符串

,并做其他的东西手动

我的方式做同样的事情自己。

回答

2

它告诉你创建迁移到删除有问题的领域,然后运行迁移

,以使其更清晰:

运行此命令:

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 

那么你就可以运行迁移做:

rake db:migrate 

这是令人困惑的,因为如果你生成“remove_silly_authentication_fields_which_should_not_be_there”迁移该类应该是RemoveSillyAuthenticationFieldsWhichShouldNotBeThere,但它会说“DropSillyControllerAttributes”,因此您应该使用drop_silly_controller_attributes生成迁移以使其保持一致

相关问题