Recent item - Routing error

2020-05-06 11:24发布

问题:

I'm encountering a really strange behaviour in my rails app. Basicaly, user is able to upload photo. The model for those photos is called user_photo. The thing is that allways, when i'll try to access the most recently added item (using the URL generated by user_photo_path(@user_photo), let's say it's http://localhost:3000/user_photos/20), i'm getting this error:

No route matches {:action=>"show", :controller=>"user_photos", :id=>nil}

This happens just to most recently added item which means that if i have a recently added user_photo with :id => 20 it will cause the routing error; however, if i'll create the new one (with :id => 21), the previous user_photo which id is 20 will start to work.

Have you any idea what can be causing this strange behaviour? I'm running my rails app in dev env using apache2 + passenger