0

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.

GCien
  • 2,221
  • 6
  • 30
  • 56
  • This should be easy to google shouldn't it? It would be "User.destroy_all" but that sounds a bit drastic. Do you really want to make all of your users sign up again? This would be very annoying for them. – Max Williams Mar 02 '15 at 10:55
  • @MaxWilliams Hi Max, as yet I am the only user as it local. So would I use rake db:User.destroy_all in the terminal... – GCien Mar 02 '15 at 10:58
  • No, just `User.destroy_all` in the console. As I said though this is so simple you should google it before putting a question on StackOverflow. – Max Williams Mar 02 '15 at 11:09
  • @MaxWilliams by console do you mean in the terminal... – GCien Mar 02 '15 at 11:49
  • To me, "the terminal" means the bash shell, if you're in Linux, or the app which Mac Os calls "terminal", which is also a bash shell. Ie, where you might type "ls -l" and see a list of files in the current directory, or run a rake task. I **do not** mean that. I mean the interactive console where you can access your Rails model code and data, and which is launched with `rails console` or `rails c` for short. http://guides.rubyonrails.org/command_line.html#rails-console – Max Williams Mar 02 '15 at 12:09
  • @MaxWilliams Another dummy question now Max, that makes total sense what you just said. Pretty straightforward. However, do I run rails c within the directory I'm working in for the website in question, then execute Users.destroy_all or change directories within the rails console... – GCien Mar 02 '15 at 12:11
  • Did you read that link? – Max Williams Mar 02 '15 at 12:16
  • @MaxWilliams Yes. From how I interpret it i would run rails c much like I would rails s from inside the app directory...but correct me if I am wrong. – GCien Mar 02 '15 at 12:19
  • Yes, that's correct, why not try it and see if it works? Sorry to be impatient but this is such basic stuff... – Max Williams Mar 02 '15 at 12:20
  • @MaxWilliams I expected a little condescension, I am very much learning. Less than 2 months. When I tried something similar I completely destroyed my app, so I want to make sure I'm interpreting things 100% correctly. I don't want to have to start from scratch again. – GCien Mar 02 '15 at 12:21
  • @MaxWilliams Excellent, worked perfectly. Thank you for your help, it must be frustrating but I am learning a whole new setup with 3-5 different languages. If you want you can add what you've just said as an answer and I will accept this. – GCien Mar 02 '15 at 12:24
  • 1
    Have added an answer. – Max Williams Mar 02 '15 at 12:25

1 Answers1

1

Start a rails console by typing

rails c

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

type

User.destroy_all
Max Williams
  • 32,435
  • 31
  • 130
  • 197