I keep getting the error message:
SQLite3::BusyException: database is locked: INSERT INTO "users" ("created_at", "email", "name", "password_digest", "updated_at") VALUES (?, ?, ?, ?, ?)
When I’m trying to execute the code:
@user = User.new(:name => "User1", :email => "email@gmail.com", :password => "password", :password_confirmation => "password")
@user.save
Is there an issue with calling save after creating the user? Do I need a timeout? If so, how do I set one up/grab a database variable.
I don’t have a clue what is going wrong here. The User variable is being created just fine as I can output the attributes of the @user variable if I remove the save function. I would just assume that I’m doing something terribly wrong. I get that I shouldn’t hard code a user, but I’m doing it for testing purposes.
What is going on here?
EDIT:
I have tried to drop my database, but it is complaining that the sqlite3 files are missing. However, when I navigate to the exact path it complains about, the files are being listed under ls.
I am assuming this is my problem. What does this mean?
Are you trying to do this while your Rails server is running?
Or have you tried to manually insert or delete rows on the table using tools like SQLite Database Browser?
Sqlite has a poor concurrency support and any action that throws the database off a little will throw Busy exception.
If the error continues to occur, and data you have in the database isn’t that important, just drop the database and migrate again. The error should be gone.