ActiveRecord :: Fixture :: FixtureError: There is no column named "monkey" in the "users" table,

Hi, I just started coding with rails, following Michael Hartl's guide, I got this error while writing a test for my application, my device is on 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') %>

      

and my db schema 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

      

I am using ruby ​​version: ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]

and rails version:Rails 4.2.6

Any suggestions please?

+3


source to share


1 answer


ActiveRecord :: Fixture :: FixtureError: There is no column named "Monkey" in the "users" table

I believe it has something to do with the indentation issue. YAML files are strictly indented. It should be



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') %>

      

Since the key monkey:

is indented incorrectly, it is treated as an attribute, just like an error.

+3


source







All Articles