Rails Console Sandbox : .save | .create

At the end of Rails Tutorial chapter 6, I have the
development .sqlite3 db : 1 table and 1 row (= user id:1 see below) :

when running from the Rails Concole Sandbox, to create other rows/records, I can
not save or create
here is what I get - Rollback - without even exiting the Rail Console ! ! !
it is like if an exception is raised somehow

1.9.3p125 :002 > user1 = User.first

User Load (0.2ms) SELECT “users”.* FROM “users” LIMIT 1
=> #<User id: 1, name: “Michael H.”, email: “[email protected]”,
created_at: “2012-05-22 10:32:16”, updated_at: “2012-05-22 10:32:16”,
password_digest: “$2a
$10$Eh2xj8CvvKaDFD2uel4LbOQ2dMsCmENy8tyts1BsFzJb…”>

1.9.3p125 :002 > user2 = User.create(name: “Francois DG”, email:
[email protected]”)

(0.1ms) SAVEPOINT active_record_1
User Exists (0.2ms) SELECT 1 FROM “users” WHERE
LOWER(“users”.“email”) = LOWER(‘[email protected]’) LIMIT 1
(0.1ms) ROLLBACK TO SAVEPOINT active_record_1
=> #<User id: nil, name: “Francois DG”, email: “[email protected]”,
created_at: nil, updated_at: nil, password_digest: nil>

CAN SOMEBODY TELL ME WHY & WHAT TO DO ?

On May 24, 2:58pm, Francesco De Grandi [email protected] wrote:

At the end of Rails Tutorial chapter 6, I have the
development .sqlite3 db : 1 table and 1 row (= user id:1 see below) :

when running from the Rails Concole Sandbox, to create other rows/records, I
can not save or create
here is what I get - Rollback - without even exiting the Rail Console ! ! !
it is like if an exception is raised somehow

Sounds like you’ve got a failing validation - user2.errors will tell
you which validations (if any) have failed.

Fred

Thank you Fred !

Meanwhile I simply realized that I had to submit a new user with all
attributes and not just 2 :

that was why the validation did not work and the transaction was rolled
back.

Thanks for the user2.errors hint…

Francesco