strange infinite loop when searching for users photos

Forums > Book - Chapter 7 > strange infinite loop when searching for users photos

Login to post a new topic

Author Message
railscoder
Member since 12 Jul 18:32
0 posts

i get into a very strange infinite loop when searching for users photos with a URL like “http://localhost:3000/users/1/photos”
it just starts looping infinitely through these three selects:
[4;36;1mSQL (0.000000)←[0m ←[0;1mSELECT count(*) AS count_all FROM photos W
ERE (photos.user_id = 1) ←[0m
[4;35;1mPhoto Load (0.000000)←[0m ←[0mSELECT * FROM photos WHERE (photos.us
r_id = 1) ORDER BY created_at DESC LIMIT 0, 9←[0m
[4;36;1mUser Load (0.000000)←[0m ←[0;1mSELECT * FROM users WHERE (users.`id = 1) ←[0m
any ideas?

railscoder
Member since 12 Jul 18:32
0 posts

Oh, that feedback i get comes from a rails console where i start the server with ruby script/server.
After uploading a photo, it redirects me to http://localhost:3000/users/1/photos and thats the end

railscoder
Member since 12 Jul 18:32
0 posts

i found the error.
in line 11 in user_photos_controller.rb, there is a comment:
it says format.html # index.rhtml
now if you take out the ’#’
you will get yourself a nice infinite loop.
sounds quite logic doesnt it?
calling the index method from within the index method?
beware of stupid people, the’re very inventive!

alan
Member since 26 Jun 23:06
0 posts

Ha! Good that you spotted that!