Skip to content

Instantly share code, notes, and snippets.

@imownbey
Created March 18, 2009 03:21
Show Gist options
  • Save imownbey/80922 to your computer and use it in GitHub Desktop.
Save imownbey/80922 to your computer and use it in GitHub Desktop.
>> user1 = User.first
User Load (0.3ms) SELECT * FROM `users` LIMIT 1
User Columns (1.7ms) SHOW FIELDS FROM `users`
=> #<User id: 1, login: "imownbey", first_name: nil, last_name: nil, email: "[email protected]", crypted_password: "855e0c5f4b94b17bde30631bde6c000af0bf1b70", salt: "68e2008908516c79514629a803f97a382e19890f", created_at: "2009-03-15 02:07:18", updated_at: "2009-03-15 02:07:59", remember_token: nil, remember_token_expires_at: nil, city_id: 76427, avatar_file_name: nil, avatar_content: nil, avatar_file_size: nil, sex: nil, status: nil, occupation: nil, birthday: nil>
>> user2 = User.last
User Load (0.4ms) SELECT * FROM `users` ORDER BY users.id DESC LIMIT 1
=> #<User id: 4, login: "iojdjf", first_name: "fdaojs", last_name: "oifjdoajfd", email: "[email protected]", crypted_password: "51df6a1bcba81a48bdb2468cdd02ae4fc5aca7bf", salt: "598f03e922f117fdded8d92977dbcbaff00d39d9", created_at: "2009-03-15 22:44:19", updated_at: "2009-03-15 22:44:19", remember_token: nil, remember_token_expires_at: nil, city_id: nil, avatar_file_name: nil, avatar_content: nil, avatar_file_size: nil, sex: nil, status: nil, occupation: nil, birthday: nil>
>> m = Message.new(:sender => user, :receiver => user2, :body => "TADA")
ActiveRecord::AssociationTypeMismatch: User(#18772310) expected, got User(#17898400)
from /Users/imownbey/Sites/repp/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:263:in `raise_on_type_mismatch'
from /Users/imownbey/Sites/repp/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb:22:in `replace'
from /Users/imownbey/Sites/repp/vendor/rails/activerecord/lib/active_record/associations.rb:1297:in `sender='
from /Users/imownbey/Sites/repp/vendor/rails/activerecord/lib/active_record/base.rb:2738:in `send'
from /Users/imownbey/Sites/repp/vendor/rails/activerecord/lib/active_record/base.rb:2738:in `attributes='
from /Users/imownbey/Sites/repp/vendor/rails/activerecord/lib/active_record/base.rb:2734:in `each'
from /Users/imownbey/Sites/repp/vendor/rails/activerecord/lib/active_record/base.rb:2734:in `attributes='
from /Users/imownbey/Sites/repp/vendor/rails/activerecord/lib/active_record/base.rb:2432:in `initialize'
from (irb):27:in `new'
from (irb):27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment