Created
May 4, 2013 04:21
-
-
Save dougo/5516162 to your computer and use it in GitHub Desktop.
Surprising behavior of ActiveRecord's order method. Can't decide if I should file this as a bug on rails/rails, or post to stackoverflow, or just suck it up and write a separate method that does the right thing.
This file contains 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
Loading development environment (Rails 4.0.0.rc1) | |
2.0.0p0 :001 > p = Post.new | |
=> #<Post id: nil, title: nil, text: nil, created_at: nil, updated_at: nil> | |
2.0.0p0 :002 > p.comments.build | |
=> #<Comment id: nil, commenter: nil, body: nil, post_id: nil, created_at: nil, updated_at: nil> | |
2.0.0p0 :003 > p.comments.size | |
=> 1 | |
2.0.0p0 :004 > p.comments.order(:created_at).size | |
=> 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment