app/controllers/application_controller.rb
def ensure_logged_in
    unless logged_in?
      session[:pre_login_destination] = "http://#{request.host_with_port}#{request.path}"
      redirect_to login_path, notice: 'You must be logged in to view this content.'
    end
  end
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
Prevent CSRF attacks by raising an exception.
For APIs, you may want to use :null_session instead.
Prevent CSRF attacks by raising an exception . For APIs you may want to use : null_session instead .
def ensure_logged_in
    unless logged_in?
      session[:pre_login_destination] = "http://#{request.host_with_port}#{request.path}"
      redirect_to login_path, notice: 'You must be logged in to view this content.'
    end
  end
def ensure_logged_in unless logged_in? session [ :pre_login_destination ] = "http://#{request.host_with_port}#{request.path}" redirect_to login_path , notice : 'You must be logged in to view this content.' end end
Prevent CSRF attacks by raising an exception.
Prevent CSRF attacks by raising an exception .