Search code examples
ruby-on-railsruby-on-rails-4sqliteruby-2.1sqlite3-ruby

Method for reseting all users in database with Ruby on Rails 4


So I've set up a new authentication process within my website using rails (rails version '4.2.0', sqlite3 database manager, ruby 2.1.1p76) on OSX Mavericks (yes, I still haven't updated yet!). The website as yet is still only local as I'm learning rails.

I have modified the user authentication to utilise a cookies remember me function, but old users can not login, i.e. error Couldn't find User (ActiveRecord::RecordNotFound in WelcomeController#homepage)

Newly created users can.

I was just wondering what the terminal command is to somehow to delete all records of users from the database, so that all new users need to sign up to obtain the remember me functionality...? I can't seem to find the exact answer and I don't want to start messing too much with the database.


Solution

  • Start a rails console by typing

    rails c
    

    in the terminal, in your rails application folder (not the app subfolder).

    type

    User.destroy_all