1

we have a web app built on rails platform and deployed using heroku. Whenever there is a new deployment, users are logged out. Is there a way to keep users logged in after the deployment??

App uses facebook login for the users to login.

rAzOr
  • 300
  • 6
  • 19

1 Answers1

1

Have you tried this in your application controller

def current_user
  if cookies[:remember_token].present?
    @current_user ||= User.find_by_remember_token(cookies[:remember_token])
  end
end
Arvind
  • 2,671
  • 1
  • 18
  • 32
  • What is remember_token?? – rAzOr Sep 21 '15 at 18:24
  • it's provide by devise http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable – Arvind Sep 21 '15 at 20:02
  • The app uses 'omniauth-facebook' for authentication not devise. How can I achieve that without devise?? – rAzOr Sep 22 '15 at 04:31
  • @rAzOr have you check this http://stackoverflow.com/questions/10497231/remember-login-with-omniauth I think this is what you are looking – Arvind Sep 22 '15 at 06:44
  • No. The app doesn't have "remember me" problem. Am using session_id for remember me. Issue is, the user is logged out when new changes are deployed to heroku which is done using `git push app_name master`. Is it because, heroku server restarts after the deployment?? – rAzOr Sep 23 '15 at 09:59
  • @rAzOr what you have written inside current_user method , could you share with me – Arvind Sep 23 '15 at 10:55
  • current_user is a single line code. It has `@current_user ||= User.find(session[:user_id]) if session[:user_id]` in it. – rAzOr Sep 25 '15 at 04:01
  • @rAzOr You storing your sessions in the database? If Yes then don't reset session as it will clear the database also if not then I think you need to generate a databse using this [link](http://stackoverflow.com/questions/2588241/rails-sessions-current-practices). – Arvind Sep 25 '15 at 08:29
  • No, Not storing the sessions in the database. Can I know why the users are logged out, after the deployment?? – rAzOr Sep 25 '15 at 09:48
  • Is it because, heroku server restarts after the deployment?? – rAzOr Sep 26 '15 at 18:38
  • I don't know more about it , but yes it could be one reason it might possible it remove all tmp file and clear cache – Arvind Sep 26 '15 at 20:06
  • Could this problem be because of [ephemeral](https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem) – rAzOr Sep 28 '15 at 04:53