ActiveRecord::Fixture::FixtureError: table "users" has no column named "monkey"
ActiveRecord::Fixture::FixtureError: table "users" has no column named "monkey"
您好,我刚开始使用 rails 进行编码,遵循 Michael Hartl 教程,我在为我的应用程序编写测试时遇到此错误,我在 test/fixtures/users.yml
上的固定装置是:
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
marwane:
name: Marwane Chahoud
email: marwane.chahoud@gmail.com
password_digest: <%= User.digest('password') %>
monkey:
name: Sterling Archer
email: sterling.archer@strange.com
password_digest: <%= User.digest('password') %>
我的数据库架构是:db/migrate/xxxxxx_create_users.rb
:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.timestamps null: false
end
end
end
我正在使用 ruby 版本:ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]
和 rails 版本:Rails 4.2.6
有什么建议吗?
ActiveRecord::Fixture::FixtureError: table “users” has no column named
“monkey”
我认为这是由于 缩进问题。 YAML 文件缩进很严格。应该是
marwane:
name: Marwane Chahoud
email: marwane.chahoud@gmail.com
password_digest: <%= User.digest('password') %>
monkey:
name: Sterling Archer
email: sterling.archer@strange.com
password_digest: <%= User.digest('password') %>
由于 key monkey:
缩进错误,它被视为 属性,错误也是如此。
您好,我刚开始使用 rails 进行编码,遵循 Michael Hartl 教程,我在为我的应用程序编写测试时遇到此错误,我在 test/fixtures/users.yml
上的固定装置是:
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
marwane:
name: Marwane Chahoud
email: marwane.chahoud@gmail.com
password_digest: <%= User.digest('password') %>
monkey:
name: Sterling Archer
email: sterling.archer@strange.com
password_digest: <%= User.digest('password') %>
我的数据库架构是:db/migrate/xxxxxx_create_users.rb
:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.timestamps null: false
end
end
end
我正在使用 ruby 版本:ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]
和 rails 版本:Rails 4.2.6
有什么建议吗?
ActiveRecord::Fixture::FixtureError: table “users” has no column named “monkey”
我认为这是由于 缩进问题。 YAML 文件缩进很严格。应该是
marwane:
name: Marwane Chahoud
email: marwane.chahoud@gmail.com
password_digest: <%= User.digest('password') %>
monkey:
name: Sterling Archer
email: sterling.archer@strange.com
password_digest: <%= User.digest('password') %>
由于 key monkey:
缩进错误,它被视为 属性,错误也是如此。