Skip to content

Instantly share code, notes, and snippets.

@jmcbri
Created February 15, 2014 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmcbri/9021337 to your computer and use it in GitHub Desktop.
Save jmcbri/9021337 to your computer and use it in GitHub Desktop.
Fresh app results:
dcid_2 $ rails c
Loading development environment (Rails 4.0.2)
irb(main):001:0> user = User.new(name: "", email: "mhartl@example.com")
=> #<User id: nil, name: "", email: "mhartl@example.com", citizen_number: nil, password: nil, created_at: nil, updated_at: nil>
irb(main):002:0> user.valid?
=> true
irb(main):003:0> user.name
=> ""
irb(main):004:0> user.name="Bob"
=> "Bob"
irb(main):005:0> user.name
=> "Bob"
irb(main):006:0> user.save
(0.1ms) begin transaction
SQL (2.2ms) INSERT INTO "users" ("created_at", "email", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 15 Feb 2014 15:56:33 UTC +00:00], ["email", "mhartl@example.com"], ["name", "Bob"], ["updated_at", Sat, 15 Feb 2014 15:56:33 UTC +00:00]]
(168.4ms) commit transaction
=> true
irb(main):007:0> user.reload
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
=> #<User id: 1, name: "Bob", email: "mhartl@example.com", citizen_number: nil, password: nil, created_at: "2014-02-15 15:56:33", updated_at: "2014-02-15 15:56:33">
irb(main):008:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment