ruby - Rails NoMethodError when raking -


i created new rails 4 app today. i've done many times. created basic user model seen here.

    class user < activerecord::base         before_save { self.email = email.downcase }         valid_email_regex = /\a[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i         validates :name, presence: true, length: { maximum: 50 }         validates :email, presence: true, length: { maximum: 100 },                     format: { with: valid_email_regex },                     uniqueness: { case_sensitive: false }         add_index :users, :email, unique: true          has_secure_password         validates :password, length: { minimum: 6 }     end 

i ran migration rake db:migrate :

    class addindextousersemail < activerecord::migration       def change         add_index :users, :email, unique: true       end      end 

my schema.rb shows migration worked:

    activerecord::schema.define(version: 20150714015826)        create_table "users", force: :cascade |t|       t.string   "name"       t.string   "email"       t.datetime "created_at",      null: false       t.datetime "updated_at",      null: false       t.string   "password_digest"     end        add_index "users", ["email"], name: "index_users_on_email", unique: true     end 

but when try verify in rails console test user model, nomethoderror: undefined method add_index. i've tried rolling , rerunning migration, no change. method defined correctly in class user < activerecord::base, , migrated db.

i'm wondering if because i'm using sqlite3 development , pg deployment(heroku) messed in regard, i'm not experienced enough on front know better. can provide gemfile if helps.

you shouldn't using add_index in model. has no place there, delete line completely.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -