Skip to content

Instantly share code, notes, and snippets.

@imajes
Created April 13, 2009 01:31
Show Gist options
  • Save imajes/94205 to your computer and use it in GitHub Desktop.
Save imajes/94205 to your computer and use it in GitHub Desktop.
## code:
this is a before_save
def save_proper_images
screenshots = []
thumbnails = []
app_images.each do |ai|
case ai["type"]
when "AppBundleIcon"
self.app_bundle_icon = AppBundleIcon.new(ai)
when "ItunesIcon"
self.itunes_icon = ItunesIcon.new(ai)
when "Screenshot"
screenshots << Screenshot.new(ai)
when "Thumbnail"
thumbnails << Thumbnail.new(ai)
end
self.screenshots = screenshots
self.thumbnails = thumbnails
AppImage.destroy_all("app_id is NULL")
end
return true
end
## output:
Processing IappsController#create (for 127.0.0.1 at 2009-04-12 18:29:39) [POST]
Session ID: b89adf5c010a9d81c90ea7429d613712
Parameters: {"app"=>"{\"price\":\"0.00\",\"seller\":\"James Brown\",\"name\":\"Modern Frog LE\",\"average_rating\":\"3.5\",\"app_images\":[{\"href\":\"http:\\/\\/a1.phobos.apple.com\\/us\\/r30\\/Purple\\/83\\/81\\/af\\/mzl.yxukglip.png\",\"app_id\":\"309424092\",\"type\":\"AppBundleIcon\",\"needs_shine\":true},{\"href\":\"http:\\/\\/a1.phobos.apple.com\\/us\\/r30\\/Purple\\/d9\\/35\\/75\\/mzl.ffynjrvv.100x100-75.jpg\",\"app_id\":\"309424092\",\"type\":\"ItunesIcon\",\"needs_shine\":false},{\"href\":\"http:\\/\\/a1.phobos.apple.com\\/us\\/r30\\/Purple\\/77\\/c0\\/b0\\/mzl.jxnxlkih.480x480-75.jpg\",\"app_id\":\"309424092\",\"type\":\"Screenshot\"},{\"href\":\"http:\\/\\/a1.phobos.apple.com\\/us\\/r30\\/Purple\\/86\\/7c\\/9c\\/mzl.obfatslp.148x99-75.jpg\",\"app_id\":\"309424092\",\"type\":\"Thumbnail\"},{\"href\":\"http:\\/\\/a1.phobos.apple.com\\/us\\/r30\\/Purple\\/86\\/7c\\/9c\\/mzl.obfatslp.480x480-75.jpg\",\"app_id\":\"309424092\",\"type\":\"Screenshot\"},{\"href\":\"http:\\/\\/a1.phobos.apple.com\\/us\\/r30\\/Purple\\/ca\\/f7\\/c7\\/mzl.tzcusxpj.148x99-75.jpg\",\"app_id\":\"309424092\",\"type\":\"Thumbnail\"},{\"href\":\"http:\\/\\/a1.phobos.apple.com\\/us\\/r30\\/Purple\\/ca\\/f7\\/c7\\/mzl.tzcusxpj.480x480-75.jpg\",\"app_id\":\"309424092\",\"type\":\"Screenshot\"},{\"href\":\"http:\\/\\/a1.phobos.apple.com\\/us\\/r30\\/Purple\\/c6\\/77\\/d9\\/mzl.itihhfbt.148x99-75.jpg\",\"app_id\":\"309424092\",\"type\":\"Thumbnail\"},{\"href\":\"http:\\/\\/a1.phobos.apple.com\\/us\\/r30\\/Purple\\/c6\\/77\\/d9\\/mzl.itihhfbt.480x480-75.jpg\",\"app_id\":\"309424092\",\"type\":\"Screenshot\"}],\"size\":\"3.7 MB\",\"category\":\"Games\",\"phobos_link\":\"http:\\/\\/phobos.apple.com\\/WebObjects\\/MZStore.woa\\/wa\\/viewSoftware?id=>309424092&mt=>8\",\"author_name\":\"Ancient Workshop\",\"ranking\":0.0,\"released_on\":\"Mar 29, 2009\",\"featured\":false,\"author_link\":\"http:\\/\\/phobos.apple.com\\/WebObjects\\/MZStore.woa\\/wa\\/viewArtist?id=>304574717\",\"version\":\"1.04\",\"author_external_link\":\"http:\\/\\/www.ancient-workshop.com\",\"languages\":\"English\",\"reviews\":671,\"requirements\":\"Compatible with iPhone and iPod touch <BR><\\/BR>Requires iPhone 2.1 Software Update\",\"description\":\"Ancient Frog, the wildly popular iPhone puzzle game, is now available in a Light Edition.<br \\/><br \\/>Ancient Frog LE - see what all the fuss is about, for free!<br \\/><br \\/>----------------------------------------<br \\/>Here&#39;s what reviewers had to say about Ancient Frog => <br \\/><br \\/>&#34;a game that is so playable, so beautiful, and so stunningly out of left field that even jaded critics like us can&#39;t help but rave about it.&#34; -- slidetoplay.com<br \\/><br \\/>&#34;This game isn\\\\u2019t just unusual to play, it\\\\u2019s also gorgeous to look at. Like all the best software, Ancient Frog benefits from attention to detail&#34; -- cultofmac.com<br \\/><br \\/>&#34;Ancient Frog has the unnerving feel - right from the off - of being the kind of game that toilet breaks were made for. And I mean in the kind of addictively brilliant way.&#34; -- chrisadampickering.co.uk<br \\/><br \\/>----------------------------------------<br \\/><br \\/>Ancient Frog is a wholly original puzzle game. The aim is to move your frog from one end of the screen to the other, to eat a delicious fly. You can only move one leg at a time, and only one foot can rest on a particular spot at a time.<br \\/><br \\/>There&#39;s no time limit. You can take your time considering your next move and watching the gentle interplay of light and shadow.<br \\/><br \\/>There&#39;s no move limit. However circuitous a route you take, eating the fly unlocks the puzzle. You can return to any puzzle at any time for another go, if you want to beat your own score.<br \\/><br \\/>You can skip any puzzle at any time from the daisy menu. If you&#39;re having trouble with a level, just move on to the next one, and come back to it later.<br \\/><br \\/>Each puzzle has a par, representing the shortest number of moves required to complete the puzzle. Achieving that perfect solution will sometimes require fiendishly twisted thinking!<br \\/><br \\/>----------------------------------------\",\"release_notes\":\"\",\"identifier\":\"309424092\"}", "action"=>"create", "controller"=>"admin/iapps", "identifier"=>"309424092", "secret"=>"ATsc08Z7mhQo"}
App Columns (0.003608) SHOW FIELDS FROM `apps`
SQL (0.000349) SHOW TABLES
App Load (0.000557) SELECT * FROM `apps` WHERE (`apps`.`identifier` = '309424092') LIMIT 1
SQL (0.000156) BEGIN
AppBundleIcon Columns (0.001438) SHOW FIELDS FROM `app_images`
WARNING: Can't mass-assign these protected attributes: type
AppBundleIcon Load (0.000379) SELECT * FROM `app_images` WHERE (`app_images`.app_id = 30333) AND ( (`app_images`.`type` = 'AppBundleIcon' ) ) LIMIT 1
AppBundleIcon Update (0.000236) UPDATE `app_images` SET `app_id` = NULL WHERE `id` = 48737377
AppBundleIcon Create (0.000171) INSERT INTO `app_images` (`href`, `app_id`, `type`, `needs_shine`) VALUES('http://a1.phobos.apple.com/us/r30/Purple/83/81/af/mzl.yxukglip.png', 30333, 'AppBundleIcon', 1)
Screenshot Columns (0.001369) SHOW FIELDS FROM `app_images`
Screenshot Load (0.001052) SELECT * FROM `app_images` WHERE (`app_images`.app_id = 30333) AND ( (`app_images`.`type` = 'Screenshot' ) )
Screenshot Update (0.000621) UPDATE `app_images` SET app_id = NULL WHERE (app_id = 30333 AND id IN (48737379,48737381,48737383,48737385)) AND ( (`app_images`.`type` = 'Screenshot' ) )
Thumbnail Columns (0.001363) SHOW FIELDS FROM `app_images`
Thumbnail Load (0.000388) SELECT * FROM `app_images` WHERE (`app_images`.app_id = 30333) AND ( (`app_images`.`type` = 'Thumbnail' ) )
Thumbnail Update (0.000774) UPDATE `app_images` SET app_id = NULL WHERE (app_id = 30333 AND id IN (48737380,48737382,48737384)) AND ( (`app_images`.`type` = 'Thumbnail' ) )
AppImage Load (0.000312) SELECT * FROM `app_images` WHERE (app_id is NULL)
AppImage Columns (0.001239) SHOW FIELDS FROM `app_images`
AppBundleIcon Destroy (0.000214) DELETE FROM `app_images`
WHERE `id` = 48737377
Screenshot Destroy (0.000147) DELETE FROM `app_images`
WHERE `id` = 48737379
Thumbnail Destroy (0.000134) DELETE FROM `app_images`
WHERE `id` = 48737380
Screenshot Destroy (0.000134) DELETE FROM `app_images`
WHERE `id` = 48737381
Thumbnail Destroy (0.000132) DELETE FROM `app_images`
WHERE `id` = 48737382
Screenshot Destroy (0.000134) DELETE FROM `app_images`
WHERE `id` = 48737383
Thumbnail Destroy (0.000132) DELETE FROM `app_images`
WHERE `id` = 48737384
Screenshot Destroy (0.000132) DELETE FROM `app_images`
WHERE `id` = 48737385
ItunesIcon Columns (0.001370) SHOW FIELDS FROM `app_images`
WARNING: Can't mass-assign these protected attributes: type
ItunesIcon Load (0.000333) SELECT * FROM `app_images` WHERE (`app_images`.app_id = 30333) AND ( (`app_images`.`type` = 'ItunesIcon' ) ) LIMIT 1
ItunesIcon Update (0.000241) UPDATE `app_images` SET `app_id` = NULL WHERE `id` = 48737378
ItunesIcon Create (0.000201) INSERT INTO `app_images` (`href`, `app_id`, `type`, `needs_shine`) VALUES('http://a1.phobos.apple.com/us/r30/Purple/d9/35/75/mzl.ffynjrvv.100x100-75.jpg', 30333, 'ItunesIcon', 0)
AppImage Load (0.000216) SELECT * FROM `app_images` WHERE (app_id is NULL)
ItunesIcon Destroy (0.000146) DELETE FROM `app_images`
WHERE `id` = 48737378
WARNING: Can't mass-assign these protected attributes: type
Screenshot Create (0.000165) INSERT INTO `app_images` (`href`, `app_id`, `type`, `needs_shine`) VALUES('http://a1.phobos.apple.com/us/r30/Purple/77/c0/b0/mzl.jxnxlkih.480x480-75.jpg', 30333, 'Screenshot', 0)
AppImage Load (0.000197) SELECT * FROM `app_images` WHERE (app_id is NULL)
WARNING: Can't mass-assign these protected attributes: type
Thumbnail Create (0.000189) INSERT INTO `app_images` (`href`, `app_id`, `type`, `needs_shine`) VALUES('http://a1.phobos.apple.com/us/r30/Purple/86/7c/9c/mzl.obfatslp.148x99-75.jpg', 30333, 'Thumbnail', 0)
AppImage Load (0.000174) SELECT * FROM `app_images` WHERE (app_id is NULL)
WARNING: Can't mass-assign these protected attributes: type
Screenshot Create (0.000291) INSERT INTO `app_images` (`href`, `app_id`, `type`, `needs_shine`) VALUES('http://a1.phobos.apple.com/us/r30/Purple/86/7c/9c/mzl.obfatslp.480x480-75.jpg', 30333, 'Screenshot', 0)
AppImage Load (0.000232) SELECT * FROM `app_images` WHERE (app_id is NULL)
WARNING: Can't mass-assign these protected attributes: type
Thumbnail Create (0.000179) INSERT INTO `app_images` (`href`, `app_id`, `type`, `needs_shine`) VALUES('http://a1.phobos.apple.com/us/r30/Purple/ca/f7/c7/mzl.tzcusxpj.148x99-75.jpg', 30333, 'Thumbnail', 0)
AppImage Load (0.000167) SELECT * FROM `app_images` WHERE (app_id is NULL)
WARNING: Can't mass-assign these protected attributes: type
Screenshot Create (0.000173) INSERT INTO `app_images` (`href`, `app_id`, `type`, `needs_shine`) VALUES('http://a1.phobos.apple.com/us/r30/Purple/ca/f7/c7/mzl.tzcusxpj.480x480-75.jpg', 30333, 'Screenshot', 0)
AppImage Load (0.000173) SELECT * FROM `app_images` WHERE (app_id is NULL)
WARNING: Can't mass-assign these protected attributes: type
Thumbnail Create (0.000234) INSERT INTO `app_images` (`href`, `app_id`, `type`, `needs_shine`) VALUES('http://a1.phobos.apple.com/us/r30/Purple/c6/77/d9/mzl.itihhfbt.148x99-75.jpg', 30333, 'Thumbnail', 0)
AppImage Load (0.000217) SELECT * FROM `app_images` WHERE (app_id is NULL)
WARNING: Can't mass-assign these protected attributes: type
Screenshot Create (0.000196) INSERT INTO `app_images` (`href`, `app_id`, `type`, `needs_shine`) VALUES('http://a1.phobos.apple.com/us/r30/Purple/c6/77/d9/mzl.itihhfbt.480x480-75.jpg', 30333, 'Screenshot', 0)
AppImage Load (0.000173) SELECT * FROM `app_images` WHERE (app_id is NULL)
SQL (0.000557) COMMIT
Completed in 0.19709 (5 reqs/sec) | Rendering: 0.00079 (0%) | DB: 0.02100 (10%) | 200 OK [http://localhost/admin/iapps]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment