I am trying to insert a new record into a SQLiteDB through my Rails console. Simply using User.create().
The row does not appear in my database.The message implies that a user exists, but calling User.first returns null and checking the database shows an empty table. What am I missing?
Input:
console > User.create(name: 'don', email: '[email protected]', password: 'test', password_confirmation: 'test')
Output:
(0.1ms) begin transaction
User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1
(0.0ms) rollback transaction
=> #<User id: nil, name: "don", email: "[email protected]", created_at: nil, updated_at: nil, password_digest: "$2a$10$3EK3L932ryjrJPFIc4E0/uzavrpkWylDRzx4Wkdwzx8d...">
User Class:
class User < ActiveRecord::Base
before_save { self.email = email.downcase }
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sen,sitive: false }
has_secure_password
validates :password, length: { minimum: 6 }
end