Ruby on Rails Saturday, December 23, 2017

I've got the program in chapter 2.

is there anything i can type in the console to reset the id? I can do e.g. User.delete_all  and delete all users, but if a new user is then created it doesn't have an id of 1 'cos the id doesn't reset.

this User.reset_primary_key   doesn't work either.

Notice how I removed all users I reset the primary key, I added a user, and they got quite a high id.
irb(main):064:0> User.first    User Load (1.0ms)  SELECT  "users".* FROM "users" ORDER BY "user  => nil  irb(main):065:0> User.primary_key  => "id"  irb(main):066:0> User.reset_primary_key  => "id"  irb(main):067:0> User.first    User Load (0.0ms)  SELECT  "users".* FROM "users" ORDER BY "user  => #<User id: 13, name: "f", email: "f", created_at: "2017-12-23 0  irb(main):068:0>


I get this error

C:\rubyarud\hartl\ch2\toy_app>rails db:drop  Permission denied @ unlink_internal - C:/rubyarud/h  Couldn't drop database 'db/development.sqlite3'  rails aborted!  Errno::EACCES: Permission denied @ unlink_internal  bin/rails:4:in `require'  bin/rails:4:in `<main>'  Tasks: TOP => db:drop:_unsafe  (See full trace by running task with --trace)


I notice the error mentions sqlite. I'm using the correct gem file, I think. https://pastebin.com/E2R77amU   I know the gemfile in the book that we are to use moves sqlite into the development and test groups. I have that and am using the gemfile that the book gives.

Is there anything I can do from the console to reset it?

Thanks

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/128e2eaa-2168-4ae9-b1fc-bcabcbb7a39a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment