My migration is as follows:
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :email t.string :password t.string :name t.boolean :male t.boolean :admin t.timestamps end end def self.down drop_table :users end end
When I go to script/console and type ‘User’, Rails does not recognize the class.
Did you run
script/generate model User ...orscript/generate migration CreateUser...?If you do not generate the model, it won’t be available in the console, as Rails doesn’t know it exists.
Rails also does not create a
modelname_idfield, it simply creates anidfield which autoincrements.I hope this helps.