Created
February 15, 2014 16:00
-
-
Save jmcbri/9021295 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/rails/apps/dcid $ rails c --sandbox | |
Loading development environment in sandbox (Rails 4.0.2) | |
Any modifications you make will be rolled back on exit | |
irb(main):001:0> user = User.new(name: "", email: "[email protected]") | |
=> #<User id: nil, name: nil, email: nil, citizen_number: nil, created_at: nil, updated_at: nil, password_digest: nil> | |
irb(main):002:0> user.email | |
=> "[email protected]" | |
irb(main):003:0> user.name | |
=> "" | |
irb(main):004:0> user.name="Bob" | |
=> "Bob" | |
irb(main):005:0> user | |
=> #<User id: nil, name: nil, email: nil, citizen_number: nil, created_at: nil, updated_at: nil, password_digest: nil> | |
irb(main):006:0> user.name | |
=> "Bob" | |
irb(main):007:0> user.valid? | |
User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER('[email protected]') LIMIT 1 | |
User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE "users"."citizen_number" IS NULL LIMIT 1 | |
=> false | |
irb(main):008:0> | |
~/rails/apps/dcid $ rails c | |
Loading development environment (Rails 4.0.2) | |
irb(main):001:0> user = User.new(name: "", email: "[email protected]") | |
=> #<User id: nil, name: nil, email: nil, citizen_number: nil, created_at: nil, updated_at: nil, password_digest: nil> | |
irb(main):002:0> user.email | |
=> "[email protected]" | |
irb(main):003:0> user.valid? | |
User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER('[email protected]') LIMIT 1 | |
User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE "users"."citizen_number" IS NULL LIMIT 1 | |
=> false | |
irb(main):004:0> user.name | |
=> "" | |
irb(main):005:0> user.name= "Bob" | |
=> "Bob" | |
irb(main):006:0> user.valid? | |
User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER('[email protected]') LIMIT 1 | |
User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE "users"."citizen_number" IS NULL LIMIT 1 | |
=> false | |
irb(main):007:0> | |
Without VALIDATIONS: | |
/rails/apps/dcid $ rails c | |
Loading development environment (Rails 4.0.2) | |
irb(main):001:0> user = User.new(name: "", email: "[email protected]") | |
=> #<User id: nil, name: nil, email: nil, citizen_number: nil, created_at: nil, updated_at: nil, password_digest: nil> | |
irb(main):002:0> user.email | |
=> "[email protected]" | |
irb(main):003:0> user.name | |
=> "" | |
irb(main):004:0> user.name = "Bob" | |
=> "Bob" | |
irb(main):005:0> user | |
=> #<User id: nil, name: nil, email: nil, citizen_number: nil, created_at: nil, updated_at: nil, password_digest: nil> | |
irb(main):006:0> user.valid? | |
=> true | |
irb(main):007:0> user.save | |
(0.1ms) begin transaction | |
SQL (13.4ms) INSERT INTO "users" ("created_at", "updated_at") VALUES (?, ?) [["created_at", Sat, 15 Feb 2014 15:40:30 UTC +00:00], ["updated_at", Sat, 15 Feb 2014 15:40:30 UTC +00:00]] | |
(147.4ms) commit transaction | |
=> true | |
irb(main):008:0> | |
irb(main):008:0> user | |
=> #<User id: 1, name: nil, email: nil, citizen_number: nil, created_at: "2014-02-15 15:40:30", updated_at: "2014-02-15 15:40:30", password_digest: nil> | |
irb(main):009:0> | |
irb(main):009:0> user.reload | |
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]] | |
=> #<User id: 1, name: nil, email: nil, citizen_number: nil, created_at: "2014-02-15 15:40:30", updated_at: "2014-02-15 15:40:30", password_digest: nil> | |
irb(main):010:0> user | |
=> #<User id: 1, name: nil, email: nil, citizen_number: nil, created_at: "2014-02-15 15:40:30", updated_at: "2014-02-15 15:40:30", password_digest: nil> | |
irb(main):011:0> | |
irb(main):011:0> user.name | |
=> "Bob" | |
irb(main):012:0> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment