Skip to content

Instantly share code, notes, and snippets.

@felixflores
Created December 16, 2009 22:52
Show Gist options
  • Save felixflores/258286 to your computer and use it in GitHub Desktop.
Save felixflores/258286 to your computer and use it in GitHub Desktop.
# WHAT!!!!
(rdb:27) @movies_for_the_week[1][:items].size
2
(rdb:27) @movies_for_the_week[1][:items]
[]
(rdb:27) @movies_for_the_week[1][:items].size
0
>> m = Movie.for_the_week
Movie Load (4.4ms) SELECT `movies`.* FROM `movies` INNER JOIN `showtimes` ON showtimes.movie_id = movies.id GROUP BY showtimes.day HAVING showtimes.day = '2009-12-16'
Movie Load (4.1ms) SELECT `movies`.* FROM `movies` INNER JOIN `showtimes` ON showtimes.movie_id = movies.id GROUP BY showtimes.day HAVING showtimes.day = '2009-12-17'
Movie Load (3.9ms) SELECT `movies`.* FROM `movies` INNER JOIN `showtimes` ON showtimes.movie_id = movies.id GROUP BY showtimes.day HAVING showtimes.day = '2009-12-18'
Movie Load (1.6ms) SELECT `movies`.* FROM `movies` INNER JOIN `showtimes` ON showtimes.movie_id = movies.id GROUP BY showtimes.day HAVING showtimes.day = '2009-12-19'
Movie Load (1.5ms) SELECT `movies`.* FROM `movies` INNER JOIN `showtimes` ON showtimes.movie_id = movies.id GROUP BY showtimes.day HAVING showtimes.day = '2009-12-20'
Movie Load (2.4ms) SELECT `movies`.* FROM `movies` INNER JOIN `showtimes` ON showtimes.movie_id = movies.id GROUP BY showtimes.day HAVING showtimes.day = '2009-12-21'
Movie Load (1.6ms) SELECT `movies`.* FROM `movies` INNER JOIN `showtimes` ON showtimes.movie_id = movies.id GROUP BY showtimes.day HAVING showtimes.day = '2009-12-22'
=> [{:date=>Wed, 16 Dec 2009, :items=>[#<Movie id: 1, title: "2312321", description: "21312321", mpaa_rating: "", created_at: "2009-12-16 21:46:24", updated_at: "2009-12-16 21:46:24", poster_file_name: "antichristposter1.jpg", poster_content_type: "image/jpeg", poster_file_size: 197301, poster_updated_at: "2009-12-16 21:46:23", trailer: "", premiere: "2009-12-16">]}, {:date=>Thu, 17 Dec 2009, :items=>[]}, {:date=>Fri, 18 Dec 2009, :items=>[]}, {:date=>Sat, 19 Dec 2009, :items=>[#<Movie id: 2, title: "32123", description: "3121321213", mpaa_rating: "", created_at: "2009-12-16 21:57:38", updated_at: "2009-12-16 21:57:38", poster_file_name: "antichristposter1.jpg", poster_content_type: "image/jpeg", poster_file_size: 197301, poster_updated_at: "2009-12-16 21:57:38", trailer: "", premiere: "2009-12-19">]}, {:date=>Sun, 20 Dec 2009, :items=>[]}, {:date=>Mon, 21 Dec 2009, :items=>[]}, {:date=>Tue, 22 Dec 2009, :items=>[]}]
>> m.each do |item|
?> puts item[:items].size
>> puts item[:items]
>> end
1
#<Movie:0x1030e0250>
0
0
1
#<Movie:0x1030cbf80>
0
0
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment