Facebook connect problem


I’m trying to allow users can connect with their facebook user. I already have the connect button, and the aplicaction indetify is there is a session or not.

Here is my problem. I create an application on facebook apps to get my key. So, when I use the facebook button the application knows who i am and reload my homepage and i can retrieve my facebook información, but when another user uses the button the open window does not close, does not reload my home, and goes directly to the user facebook homepage. In this case, my application identify there is a session but only display my information (if I am friend from the logged user) or does not display anything in other case. The session always has the facebook app information (keys, uid, etc)

What i am doing wrong? I prove using both Rails (rfacebook) and only HTML/Javascripts