antirez / lamernews

Lamer News -- an HN style social news site written in Ruby/Sinatra/Redis/JQuery
http://lamernews.com
Other
1.35k stars 200 forks source link

Wrong user account displayed on front page #86

Open mhdingler opened 13 years ago

mhdingler commented 13 years ago

Just went to the lamernews front page and the wrong user profile was shown in the right hand corner.

Screenshot: http://i.imgur.com/s5R9R.png

My user name: mhd Wrong user: deivinsontejeda

Back to normal on reload. Couldn't reproduce error after that.

System: Firefox 7.0.1 (OS X 10.7.2) w/ AdBlock and Ghostery add-ons

antirez commented 13 years ago

Probably due to the fact that I use a global for $user ?

Apparently in Sinatra globals are shared among the whole environment, will switch to Sinatra properties soon to fix that. Thanks for reporting.

EDIT: I don't think properties are a good fix either. The current user should probably be instead set into an instance variable, even if this poses problems accessing it from the HTMLGen object H... I'm trying to understand better how scoping works in Sinatra but there is not much documentation about things like how concurrency is handled, scope of different kind of variables/methods and so forth.